What wrong with this code

Started by
37 comments, last by Tiffany Smith 20 years, 10 months ago
This code is supposed to work but it doesn''t every time i start the program it shuts off how can i fix it? #include <iostream.h> int main() { cout<<"hello i am rookie developers first program"; return 0; } Thanks for reading my post please help if I need help, alot of help; goto forum
Go to my home pagehttp://angelfire.com/games5/risingsuninc
Advertisement
The program ends without waiting for a response from the user. If you ran that from the command prompt, you would see your text.
uhh could you give me an example of that?
Go to my home pagehttp://angelfire.com/games5/risingsuninc
LMFAO


#include <iostream.h>
//use the header conio.h for getch()
#include <conio.h>

int main()
{
cout<<"hello i am rookie developers first program";


//Use getch to get a response from the user to quit
//So basicly it will pause and once the user presses a button
//the program will close but you can read everything before that
getch();

return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                                          
Looking for video game music? Check out some of my samples at http://www.youtube.c...ser/cminortunes            
                                                          
I'm currently looking to create music for a project, if you are interested e-mail me at cminortunes@gmail.com    
                                                          
Please only message me for hobby projects, I am not looking to create music for anything serious.
Your code is working but cause it''s in a DOS window it displays it and then closes the window so fast that you don''t see it. Try adding this after your cout statement:

cin.get()


You could also try to call up a DOS window and just execute it from there and it then won''t close the window for ya.
ok thanks
Go to my home pagehttp://angelfire.com/games5/risingsuninc
How can I find my first post?
i tried both of those things and neither worked i even copied the example but it didnt even work. im am using devC++ is there something wrong with my compiler

if I need help, alot of help;
goto forum
Go to my home pagehttp://angelfire.com/games5/risingsuninc
Try this:

#include <iostream.h>#include <stdlib.h>   // Add this so you can use system("PAUSE")int main(){ cout<<"hello i am rookie developers first program"; system("PAUSE"); return 0;}


[edited by - Mscgamer on June 16, 2003 4:49:26 PM]
Any of these three should work:
#include <iostream>#include <cstdlib> int main(){    std::cout << "I am rookie_developer''s first program!\n\n";    system("PAUSE");    return 0;}

#include <iostream> int main(){    std::cout << "I am rookie_developer''s first program!\n\n"              << "Press any key to continue . . . ";    std::cin.get();     return 0;}

#include <iostream>#include <conio.h> int main(){    std::cout << "I am rookie_developer''s first program!\n\n";    getch();     return 0;}


[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]

This topic is closed to new replies.

Advertisement