Jump to content
  • Advertisement
Sign in to follow this  
pven

My work is still jumping for a second and gone.

This topic is 3558 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

http://www.gamedev.net/community/forums/topic.asp?topic_id=487824 This person had the same problem as me, but it still doesnt work for me. #include <iostream.h> using namespace std; int main() { int score; double distance; char playAgain; bool shieldsup; short lives, aliensKilled; score = 0; distance = 1200.76; playAgain = `y'; shieldsUp = true; lives = 3; aliensKilled = 10; double engineTemp = 6572.89; cout << "\nscore: " << score << endl; cout << "distance: " << distance << endl; cout << "lives: " << lives << endl; cout << "aliensKilled: "<< aliensKilled << endl; cout << "engineTemp: " << engineTemp << endl; int fuel; cout << "\nHow much fuel? "; cin >> fuel; cout << "fuel: " << fuel << endl; typedef unsigned short int ushort; ushort bonus = 10; cout >> "\nbonus: " << bonus << endl; cout << "\nPress the Enter Button"; cin.ignore(cin.rdbuf()->in_avail() + 1); system("pause"); return 0; } It still flashes after the last command that was appointed in the other thread what am I doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by pven
It still flashes after the last command that was appointed in the other thread what am I doing wrong?


system("pause"); will only request you to press any key to continue. When you press the key, your program will shut down, because it ends. Is this the problem? If so, replace that with while(1) system("pause"); and your program will never shut down.

If you want window not to close after it ends, create a shortcut (place it to your desktop, for example), edit it's properties and check box with something like "Do not close window when program ends".

Share this post


Link to post
Share on other sites
Do you mean like this?

while(1) system("pause");

Tested it out, the compiling works perfect but when i debug it still just flashes away. Tried the thing with the shortcut to didnt find it :/ Im using Vista x64 Ultimate..

Share this post


Link to post
Share on other sites
This has been answered a million and a half times. Just run the program from the console, as it is meant to be (it's a console program, after all).

And on a side note, I suggest installing Microsoft's "Open Command Window Here" PowerTool, so that you can right-click on the debug folder and have a command prompt open to that directory.


system("PAUSE") only works on Windows, anyway.

Share this post


Link to post
Share on other sites
Ezbez: Now I have tried to run it in cmd.exe but it still flashes away faster than I can blink.

Share this post


Link to post
Share on other sites
I have used this solutions both in Microsoft Visual 2008 Studio and in the command promt and it still flashes away :/


cout << "Press the enter key to exit";
cin.ignore(std::cin.rdbuf()->in_avail() + 1);

cout << "Press the enter key to exit";
cin.ignore(std::cin.rdbuf()->in_avail() + 1);
system("pause");

system("pause");
cout << "Press the enter key to exit";
cin.ignore(std::cin.rdbuf()->in_avail() + 1);

system("pause");


while(1) system("pause");
cout << "\nPress the Enter Button";
cin.ignore(cin.rdbuf()->in_avail() + 1);

cout << "\nPress the Enter Button";
cin.ignore(cin.rdbuf()->in_avail() + 1);


All this combinations have been tried and i still dont get it to work.

Share this post


Link to post
Share on other sites
This just makes no sense to me. What does "flashes away" mean? Can you be more descriptive?

while(1); should have your program looping forever. If it doesn't, call an exorcist.

Share this post


Link to post
Share on other sites
Quote:
Original post by Hollower
This just makes no sense to me. What does "flashes away" mean? Can you be more descriptive?

while(1); should have your program looping forever. If it doesn't, call an exorcist.


Or may I suggest a visit to your local debugger? Microsoft's Visual Studios Express Edition has quite a competent debugger.


As for the "flashes away" - huh? There's nothing to flash if you run it from the command line. It should just run the program and the show all output. If there's no output, it would go straight to the next command. No new window should be made, unless you're making one.

Share this post


Link to post
Share on other sites
Flashes away means that the command prompt just pops up for like a millisecond, executes the command and then disappears so quickly that you don't even have time to see the output.


Something as simle as:

int n;
cin>>(n);


should make the command promt stay until the next time i press enter?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!