Stack Overflow Asked by harsh varma on December 7, 2021
#include<stdio.h>
int main()
{
printf("hello worldn");
return 0;
}
There is no error while compiling but when i try to run the code the error is:
./hello.c: line 2: syntax error near unexpected token'('
./hello.c: line 2: 'int main()'
How can i solve this because ive tried everything and i dont think there is a syntax error.
You don't run the .c
file from the shell. After you compile the program, you run the executable that was created.
So if you compiled it like:
gcc -o hello hello.c
Then you run it with
./hello
When you use ./hello.c
, the shell tries to run your C source code as a shell script. That won't work because they're completely different languages.
Answered by Barmar on December 7, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP