Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

rookie_developer

What wrong with this code

This topic is 5574 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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 ]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!