Beginner: syntax error before int main ()

后端 未结 2 1593
情歌与酒
情歌与酒 2021-01-02 10:56

I\'m trying to run a Hello World program but am getting the error

./ex1.c: line 3: syntax error near unexpected token `(`
./ex1.c: line 3: `int main (int arg         


        
相关标签:
2条回答
  • 2021-01-02 11:37

    You can't run a .c file just by using ./ex1.c; you have to compile it into a runnable program first.

    Assuming you have a Linux/OS X machine, use gcc -Wall ex1.c -o ex1 to compile it (or, more simply, make ex1). Then you can ./ex1 to run the program.

    0 讨论(0)
  • 2021-01-02 11:47

    After you compile the program by using make "your program name" (like make mario in this case), then just use ./"your program name" (this case ./mario). DO NOT add .c when running the program.

    0 讨论(0)
提交回复
热议问题