the window keeps disappearing.!!!!!!

Started by
9 comments, last by articwolf3805 21 years, 7 months ago
i''ve read the book for this question and got responses from people on this and none of it works!I compile it then run it and the window comes up and quickly dissappears....poof...gone.now what?
Come to the arctic domain!http://articdomain.netfirms.com
Advertisement
Uhhh...not sure what you''re talking about...

John.
Use MS-Dos to initiate the program. There are ways to change your source to fix this too, but I just prefer this way.

_____________________________

And the Phoenix shall rise from the ashes...

--Thunder_Hawk -- ¦þ
______________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
thats what im doing
Come to the arctic domain!http://articdomain.netfirms.com
Sorry give all information you can think of, for one I''m assuming a dos program. I''d watch out for abort statements too.
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
This might work. Call wait() before exiting main().

    #include <iostream>using namespace std;void wait(){	cout << endl << "Press <enter> to continue";	char enter;	cin.getline(&enter, 1);}      


[edited by - WoR on September 10, 2002 6:27:23 PM]
Did we not answer that question in this thread?

[twitter]warrenm[/twitter]

yea zealous but there has to be a way to make the window stay up without putting a system pause on it
Come to the arctic domain!http://articdomain.netfirms.com
quote:Original post by articwolf3805
yea zealous but there has to be a way to make the window stay up without putting a system pause on it


arcticwolf, I think what you are trying is best answered with some previous suggestions in your other post. Mainly getting a book to help learn the language.

The reason your window is closing so quickly is because you haven't told the code to do anythign else. The code starts at main() and goes line by line as fast as possible until it's done. If you tell it to PAUSE somewhere, it will, but as soon as it's done it will continue on. When it hits the end of the main() procedure, it's going to close like it is.

So you need to learn about loops and control statements, and figure out what you are trying to do... If you are interested in making a game, start out with a High/Low Guess the number style of game. This is probably one of the easiest to create.

I'll try to help you get started... Here is some flow statements to show how the program would be designed...

01) PROGRAM START (   main()    )02) Random Number Generator is seeded (srand(time(NULL)03) Program picks a random #04) Start a While Loop that waits until the user guesses the number.05) Program Displays a prompt to the user, asking him to pick a number06) Program checks the users input to see if it's higher or lower than the random number.07) If Higher, Tell the user he was too high, and loops back to 04.08) If Lower, Tell the suer he was too low, and loop back to 04.09) If Guessed, then exit out of the While loop.10) After the while loop, Congratulate the player for guessing the number.11) End Program  


Now, to write this program, you are going to have to know how to use a few commands, I think the following would be sufficient.


      srand(time(NULL)); //You probably won't have to worry about knowing what this means right now. But any program that uses RANDOM NUMBERS has to have this in the main() function, or the random numbers will always be the same. Also, you will need to #include <time.h> for this to work.if( statement ) {};  // The IF statement is one of the most important to any programming language. Look around for sample programs to see it's format.cin; and cout; //These are used to input and output characters to the screen. the format is a little strange, but goes like this... //examplescout<<"Hello"; //Outputs Helloint a_var; //Creates an integer variable called 'a_var'cin>>a_var //takes whatever the user types and stores it in 'a_var'/////////while() //The while statement is a control statment that causes a loop while a certain variable condition is true.    


That SHOULD be enough commands to create the Guess the Number Program.. I might of left something simple out though... I hope I haven't rambled too much, and hopefully this post is at least somewhat helpful.

If you have any questions, post away!




~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~
--edit typo

[edited by - Radagar on September 10, 2002 8:19:42 PM]

[edited by - Radagar on September 10, 2002 8:20:56 PM]
WyrmSlayer RPG - In Early Development
quote:Original post by articwolf3805
yea zealous but there has to be a way to make the window stay up without putting a system pause on it


You, sir, are wrong. Additionally, you have no understanding of how your command line interpreter functions, nor do you understand the process of program execution. The ONLY way to make your "window" persist is to run it from the command line, or insert code that causes it to wait for input before it terminates.

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[twitter]warrenm[/twitter]

This topic is closed to new replies.

Advertisement