--- In [email protected], <[EMAIL PROTECTED]> wrote:
>
> I opened up a GNOME terminal in SuSe 10.1 and tried a simple C
> program
> but after I typed
>
> printf(âhello\nâ);
>
> I got a âsyntax error near unexpected tokenâ indication.
> Does that have anything to do with the GNOME Iâm running in
> SuSe.
I'm pretty sure this is not the case here.
Look, in ANSI C programming you will always have to eventually provide
a "main()" function to the compiler; the reason is that the so-called
"runtime system" will evoke the function "main()" when it tries to
execute your program.
Now in order to compile and run a program, you will have to provide
several things to the compiler:
- a file containing the main() function,
- enough disk space (sounds stupid, but real life...)
The file containing the main() function should in your case look like
this:
#include <stdio.h>
int main( void)
{
printf( "Hello world!\n");
}
Then you can (hopefully) compile this into an executable program:
cc -c myprog.c
cc -o myprog myprog.o -lc
and then execute this program by typing:
./myprog
Now your piece of code shows some code which can be placed within the
main() function. But where is the main() function itself? Could it be
that you forgot to type the lines
int main()
{
and
}
which begin and end the main() function?
Also I have noticed that your original line of code:
> printf(âhello\nâ);
looks funny. What's the special characters you've inserted between (
and hello? Are you sure this is on your computer the character named
"double quote", ASCII code 34? If it's not, then your compiler won't
understand that you want to give a string expression here, and so it
can't compile correctly.
Regards,
Nico