I have a .c file with a program (obviously written in C):
#include <stdlib.h>
int main(int argc, char** argv) {
printf("Hello World\n");
return 0;
}
I'm having problems running it.
At first, this happened:
$ ./file.c
bash: ./file.c: Permission denied
I then added execute permissions with chmod +x file.c, but it still didn't work:
$ ./file.c
./file.c: line 3: syntax error near unexpected token `('
./file.c: line 3: `int main(int argc, char** argv) {'
However, as far as I know, this C program should be syntactically correct.
How do I execute it?
C files cannot be executed, they must be compiled into an executable first.
For example:
Given a C file called "file.c"
gcc file.c -o executable./executableIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With