Saturday, May 22, 2010

Anyone know C++???!? Here is my code, how do I get the window to stay up?

instead of flash and disappear??





/* my second program in C++


with more comments */





#include %26lt;iostream%26gt;


using namespace std;





int main ()


{


cout %26lt;%26lt; "Hello World! "; // prints Hello World!


cout %26lt;%26lt; "I'm a C++ program"; // prints I'm a C++ program


return 0;


}





what code do I use and where does it go?

Anyone know C++???!? Here is my code, how do I get the window to stay up?
Neebler is right. The program finishes and exits before you can see the output. #include %26lt;stdio.h%26gt; and use the getch() function which waits to read a character from the keyboard or using #include %26lt;string%26gt; with string input; cin %26gt;%26gt; input;
Reply:I assume you are running this from MS Visual C++. I usually set a breakpoint on the last line (return 0).





You could also do a getch() or cin %26gt;%26gt; string to wait for input just before the return 0.

nil

No comments:

Post a Comment