开发者

Passing string into function. expected expressing before ']' token. Using C

开发者 https://www.devze.com 2023-04-01 21:42 出处:网络
I\'m back again with another string problem. I\'ve no idea what\'s wrong with this. I\'m trying to pass a string into a function but GCC expects an expression from me. Help is appreciated. These error

I'm back again with another string problem. I've no idea what's wrong with this. I'm trying to pass a string into a function but GCC expects an expression from me. Help is appreciated. These errors are always so hard to debug!

if (fmenu == 1)
{      
 pri开发者_JAVA技巧ntf("\nEnter the file name: \n");
 scanf("%s", name);
 /* printf("filename: %s", name); */
     smenu = sndmenu();

    if (smenu !=1 && smenu !=2 )
    {
        printf("\nIncorrect option\n");
     smenu = sndmenu();     

     if (smenu == 1)
      file = fileoperations(name[]); /* Here, I cannot pass name[], expected expression */
     }    
}


name[] isn't a valid expression.

You need fileoperations(name);


sndmenu - what is that?

If this is homework I think that it is better that you stuggle for a while. Try a debugger. Try commenting out lines and replacing them with simpler lines to gain an understanding.

0

精彩评论

暂无评论...
验证码 换一张
取 消