Re: [newbie] c compiler and its problem in 8.0
On Mon, 31 Dec 2001, Pen Gwynne wrote: Eric, Please do gcc -v or cc -v and tell us what it says. I have the following 4 line program: int main() { printf(Hello World!); } - snip -- Now let me say this. My prompt is the normal, or default [pen@myhost dir]$ When I run the program what I see is: Hello World![pen@myhost dir]$ For a start you could try adding \n to the end of the string. That should separate the message and the prompt. printf(Hello World!\n); You should also be aware of one more funny thing that Linux does. After running a.out, the hello world example, As soon as I type something, anything, then the hello world program output and my prompt line: Hello World![pen@myhost dir]$ is comes just: [pen@myhost dir]$ Not sure I understand what you are saying, but any output from the program will be buffered until the shell sees a newline. It looks like the program never printed anything at all. Hope this helps. /Pen -- Len Lawrence @ The Thistle Foundation Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [newbie] c compiler and its problem in 8.0
What warnings are you getting? Anyway, you need to add a return value unless you change to function from int main() to void main(). void main() is considered to be bad programming though. Add return 0; as your last line in the main() function. That will return the integer value of 0 (zero) to the system and is required if you use int main(). The int in int main() means that you are returning an integer value to the operating system. You should have a statement of #include stdio.h at the beginning of the program, also. Usually, a compiler will complain unless you include a header file with the function prototype and the compiler normally complains if you declare a function with a return value but don't provide a return value statement within the body of the function (the data types have to match also). At 05:52 PM 12/31/2001 -0500, eric wrote: Dear Pen: I tried your 4 lines program, it still not print out even I use gcc -v or cc -v to compile, actually after the gcc -v I got a lot of junks waring. Same thing, at bash it is not be printed, but it can be shown at csh. rpm -q gcc 2.96-0.48mdk (probably straight from 8.0 standard edition) rpm -q bash bash-2.04-18mdk(straight from 8.0 standard edition) you may check your bash in your 8.1 , is that same edition as mine in 8.0? may be that is the problem. eric, [EMAIL PROTECTED] Pen Gwynne wrote: Eric, Please do gcc -v or cc -v and tell us what it says. I have the following 4 line program: int main() { printf(Hello World!); } It compiles and run properly, even without the normal #include files. I am using a straight Mandrake 8.1 installation and my version of gcc is 2.96 2731. Now let me say this. My prompt is the normal, or default [pen@myhost dir]$ When I run the program what I see is: Hello World![pen@myhost dir]$ You should also be aware of one more funny thing that Linux does. After running a.out, the hello world example, As soon as I type something, anything, then the hello world program output and my prompt line: Hello World![pen@myhost dir]$ is comes just: [pen@myhost dir]$ It looks like the program never printed anything at all. Hope this helps. /Pen Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [newbie] c compiler and its problem in 8.0
Eric, Please do gcc -v or cc -v and tell us what it says. I have the following 4 line program: int main() { printf(Hello World!); } It compiles and run properly, even without the normal #include files. I am using a straight Mandrake 8.1 installation and my version of gcc is 2.96 2731. Now let me say this. My prompt is the normal, or default [pen@myhost dir]$ When I run the program what I see is: Hello World![pen@myhost dir]$ You should also be aware of one more funny thing that Linux does. After running a.out, the hello world example, As soon as I type something, anything, then the hello world program output and my prompt line: Hello World![pen@myhost dir]$ is comes just: [pen@myhost dir]$ It looks like the program never printed anything at all. Hope this helps. /Pen Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [newbie] c compiler and its problem in 8.0
Dear Pen: I tried your 4 lines program, it still not print out even I use gcc -v or cc -v to compile, actually after the gcc -v I got a lot of junks waring. Same thing, at bash it is not be printed, but it can be shown at csh. rpm -q gcc 2.96-0.48mdk (probably straight from 8.0 standard edition) rpm -q bash bash-2.04-18mdk(straight from 8.0 standard edition) you may check your bash in your 8.1 , is that same edition as mine in 8.0? may be that is the problem. eric, [EMAIL PROTECTED] Pen Gwynne wrote: Eric, Please do gcc -v or cc -v and tell us what it says. I have the following 4 line program: int main() { printf(Hello World!); } It compiles and run properly, even without the normal #include files. I am using a straight Mandrake 8.1 installation and my version of gcc is 2.96 2731. Now let me say this. My prompt is the normal, or default [pen@myhost dir]$ When I run the program what I see is: Hello World![pen@myhost dir]$ You should also be aware of one more funny thing that Linux does. After running a.out, the hello world example, As soon as I type something, anything, then the hello world program output and my prompt line: Hello World![pen@myhost dir]$ is comes just: [pen@myhost dir]$ It looks like the program never printed anything at all. Hope this helps. /Pen Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [newbie] c compiler and its problem in 8.0
eric wrote: Dear mandrake 8.0 standard user: I used simple c program hello world, in printf(hello world) it did not print at all, until I add \n\n at the end of the line of hello world, then it print as what it should be. but that kind of result is not correct. it never happen at redhat 7.1 or debian-progeny 1.0, they all can print even without \n\n at the end of string. need help, and thanks inn advance, eric lin, http://www.onlineexchange.com/shilin url so far, will add later What that means is that our compiler is stricter... It insists on proper C code. Civileme Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [newbie] c compiler and its problem in 8.0
Dear tester: Thanks your fast replay, but whether put \n or not put \n at string will violate the c syntax so it wont print in printf still worth to discuss-I will check my c programming book later to discuss with our community. /* I actually download and install many new gcc and its related mdk.rpm from cooker, it still not work the way redhat or debian work */. url:http://www.ezinfocenter.com/4436786 http://www.onlineexchange.com/shilin tester wrote: eric wrote: Dear mandrake 8.0 standard user: I used simple c program hello world, in printf(hello world) it did not print at all, until I add \n\n at the end of the line of hello world, then it print as what it should be. but that kind of result is not correct. it never happen at redhat 7.1 or debian-progeny 1.0, they all can print even without \n\n at the end of string. need help, and thanks inn advance, eric lin, http://www.onlineexchange.com/shilin url so far, will add later What that means is that our compiler is stricter... It insists on proper C code. Civileme Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com