Friday, July 31, 2009

Hello World! Error,I think?

When ever I do the hello world project on the dev-c++ complier


It runs and compiles but no window pops up.


I keep the first source code then make a new one.


Any idea,Iv tried many different Hello World! project codes but non work

Hello World! Error,I think?
try this





#include %26lt;iostream%26gt; // if u see a error try putting this #include %26lt;iostream.h%26gt; for older compiler


using namespace std;





int main(){





cout %26lt;%26lt;" HELLO WORLD" %26lt;%26lt; endl;





system("PAUSE");


return (1);


}








try it again i fixed 1 mistake i made earlier.
Reply:after it compiles and you save it, you have to execute the exe file if i remember correctly.
Reply:Typically a hello world would print out the text on a DOS prompt, but it would immediately close.


To be sure, you need to do the following:





#include %26lt;stdio.h%26gt;


void main(void)


{





printf("\n Hello World");


getchar();


return;


}








Basically, the API


int getchar ( void ); %26lt;cstdio%26gt;


Get character from stdin


Returns the next character from the standard input (stdin).


It is equivalent to getc with stdin as its argument.





The changes above makes your program waits for any key to be pressed by the user (YOU), and will not exit.





Try it!

sympathy flowers

No comments:

Post a Comment