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
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.
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.