Error for a very simple C program
Hi there,
I am a newbie to Linux. The objective of mine is to learn programming on Linux and get rid of Windows. I hate Windows. In LINUX Answers section of this forum, a simple program of C is published. The program does just a simple printf of some text and nothing else. I am getting an error in Linux. I have Linux red hat 9. To cross check if C compiler is present, I did a " which gcc " command in the terminal. I got a reply /usr/bin/gcc . I assume that this means that the compiler is present on the system. On writing the simple following program: # include<stdio.h> main() { printf("Linuxquestions.org\n"); } I get an error which says : bash:syntax error near unexpected token '(printf ' I wonder what this means. Help on this regard would be appreciated. Also, it would be great if people can suggest some good books to buy for programming C on Linux. Thanks in advance for your help. Cheers PK P.S : I have logged on as localhost : root. Could this be a reason for the error? Just thinking aloud .................. |
you have to compile the source code
gcc -o executable filename.c replace executable with the name you want and filename with the name of the source file. and then run ./executable What you are trying to do is run the source code as an executable. C is a compiled language, so you have to run gcc on your source code to turn it into machine language skel |
Code:
# include<stdio.h> Code:
# include<stdio.h> Code:
# include<stdio.h> Code:
# include<stdio.h> |
All times are GMT -5. The time now is 10:14 AM. |