You've got a space in your include statement:
#include <stdio.h>
int main(int argc, char *argv[]) { Printf("\nHello World!\n"); return(0); }
Never protoctype main as a void function or else you can't get a return value back to the operating system.
-brian
Brian D. McGrew { brian@visionpro.com || brian@doubledimension.com } --
Those of you who think you know it all,
really annoy those of us who do!
-----Original Message----- From: fedora-list-bounces@redhat.com [mailto:fedora-list-bounces@redhat.com] On Behalf Of Dotan Cohen Sent: Monday, October 31, 2005 11:03 AM To: For users of Fedora Core releases Subject: gcc not compiling
I'm just getting started in programming C. My first attempt: #include < stdio.h> void main () { printf("\nHello World!\n"); }
Threw this error: [dotancohen@localhost ~]$ gcc hello.c hello.c:1:20: error: stdio.h: No such file or directory hello.c: In function 'main': hello.c:3: warning: incompatible implicit declaration of built-in function 'printf' hello.c:2: warning: return type of 'main' is not 'int' hello.c:4:2: warning: no newline at end of file
So I googled for "1:20: error: stdio.h: No such file or directory" and found a post that suggests that the answer to the problem is found in the gcc manual. So I started reading it, but it is long and I'm not finding anything!
I think that I'm missing a library stdio.h but I don't know where to find it, and where to put it once I do find it. Or am I completly wrong? The error message is pretty clear.
Dotan Cohen http://technology-sleuth.com/question/how_can_i_be_safe_online.html
On Mon, Oct 31, 2005 at 11:05:41AM -0800, Brian D. McGrew wrote:
Never protoctype main as a void function or else you can't get a return value back to the operating system.
Sure you can:
#include <stdio.h> void main () { printf("\nHello World!\n"); } $ gcc -o foo foo.c foo.c: In function `main': foo.c:2: warning: return type of 'main' is not `int' $ ./foo Hello World! [ddm@archonis ~] $ echo $? 14 As written, the program returns the value of the last expression executed. In this case, printf() printed 14 characters, and the program returns that number.
However, it should be noted that this behavior is not defined by the standard, and can't be depended upon. But if you don't want that, no problem:
#include <stdio.h> void main(void) { Printf("\nHello World!\n"); exit(0); } gcc -o foo foo.c foo.c: In function `main': foo.c:2: warning: return type of 'main' is not `int' [ddm@archonis ~] $ ./foo Hello World! [ddm@archonis ~] $ echo $? 0 You can return whatever value you like by calling exit().
dear Cohen Brian is right!!! 'main' should always declare as either he sugested or can also int main( ) { /*body*/ return 0; } and trie to compile by issuing following command at terminal:- gcc -Wall -o NameOfExecutableFile fileName.c and run it:- ./NameOfExecutableFile
On 11/1/05, Brian D. McGrew brian@visionpro.com wrote:
You've got a space in your include statement:
#include <stdio.h>
int main(int argc, char *argv[]) { Printf("\nHello World!\n"); return(0); }
Never protoctype main as a void function or else you can't get a return value back to the operating system.
-brian
Brian D. McGrew { brian@visionpro.com || brian@doubledimension.com }
Those of you who think you know it all,
really annoy those of us who do!
-----Original Message----- From: fedora-list-bounces@redhat.com [mailto:fedora-list-bounces@redhat.com] On Behalf Of Dotan Cohen Sent: Monday, October 31, 2005 11:03 AM To: For users of Fedora Core releases Subject: gcc not compiling
I'm just getting started in programming C. My first attempt: #include < stdio.h> void main () { printf("\nHello World!\n"); }
Threw this error: [dotancohen@localhost ~]$ gcc hello.c hello.c:1:20: error: stdio.h: No such file or directory hello.c: In function 'main': hello.c:3: warning: incompatible implicit declaration of built-in function 'printf' hello.c:2: warning: return type of 'main' is not 'int' hello.c:4:2: warning: no newline at end of file
So I googled for "1:20: error: stdio.h: No such file or directory" and found a post that suggests that the answer to the problem is found in the gcc manual. So I started reading it, but it is long and I'm not finding anything!
I think that I'm missing a library stdio.h but I don't know where to find it, and where to put it once I do find it. Or am I completly wrong? The error message is pretty clear.
Dotan Cohen http://technology-sleuth.com/question/how_can_i_be_safe_online.html
-- fedora-list mailing list fedora-list@redhat.com To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
-- fedora-list mailing list fedora-list@redhat.com To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
-- Sagittarius
"Darkness of this UNIVERSE has many secrets."
On 11/3/05, ice ice.simx@gmail.com wrote:
dear Cohen Brian is right!!! 'main' should always declare as either he sugested or can also
int main( ) { /*body*/ return 0; }
and trie to compile by issuing following command at terminal:-
gcc -Wall -o NameOfExecutableFile fileName.c
and run it:-
./NameOfExecutableFile
Sagittarius
"Darkness of this UNIVERSE has many secrets."
Thank you Sagittarius. Yes, Brian was most certainly right. Thanks to all who went over my code and corrected my mistakes. I do appreciate that.
Dotan Cohen http://lyricslist.com/lyrics/artist_albums/302/lauper_cyndi.php Lauper, Cyndi Song Lyrics
2