简体   繁体   中英

: syntax error near unexpected token `('?

Can anyone tell where the problem is?

someone@someone:~/Desktop$ cat morning.c
#include <stdio.h>
int main (int argc, char** argv)
{ 
  printf ("Good Morning") ; 
  return 0;
}
someone@someone:~/Desktop/9raya$ ./morning.c
./morning.c: line 2: syntax error near unexpected token `('
./morning.c: line 2: `int main (int argc, char** argv)'

I really don't see where the problem is.

The problem is that you're trying to execute C source code and your shell doesn't understand that. You need to compile the source code into an executable, then execute it. For example,

Compile morning.c to produce an executable named morning :

gcc -Wall -Wextra morning.c -o morning

Execute morning :

./morning

where I added the -Wall and -Wextra flags to provide a more useful set of compiler warnings on top of gcc's quite minimal default.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM