PDA

View Full Version : c program


Lamvuong
11-06-2002, 02:32 PM
hi i am new to linux... what the problem is compiling...

its a simple code but i dont know how to compile and then run the stupid thing.

using emacs to write code and console to compile.
everything compile with no error

#include <stdio.h>

main()
{
printf("hello");
}

well its not about skills of programing here the problem is when i compile there is no error and when i run ./a.out no output is display is linux extended or something command i used to compile is gcc (filename) please tell me how to compile and run i am using redhat 8.0 psyche thanks

GiangVu
11-06-2002, 03:16 PM
[root@gl /]# ./test.c
./test.c: line 5: syntax error near unexpected token `"hello"'
./test.c: line 5: `printf("hello"); '

you need to chmod that file first... to be able to compile :p

vstyle
11-06-2002, 04:01 PM
i thinks it's supposed to be
int main()
{
printf("Hello World");
return 0;
}

to compile it, just run "make test"

Lamvuong
11-06-2002, 05:20 PM
well code looks okay to me and no main dont need to de declare as int, and it dont need to return 0 if not declared run make its okay but when run compile product no outputs on screen to confirm i tried this code on redhat 6.0 works fine a.out execute no problem is there a special command change in 8.0? to futher confirm 7.1 works too... i think i will download 7.3 to see if that works and stick to 7.3... i would be very greatfull if someone can tell me whats wrong with 8.0 and if they have added commands to compile.