![]() |
simple error
#include <iostream.h>
main() { int numcheck, number, guessnum, guesscounter; while (numcheck = 0) { cout << "Enter a number between 1 and 100\n"; cin >> number; numcheck=0; if (number < 1) { numcheck = 1; } if (number > 100) { numcheck = 1; } } return 0; } the window pops up but then closes before you can do anything Can someone help me please. :banana: |
Initialize numcheck to zero:
:
main() {and read the forum rules, it clearly states you should use code tags. |
yeah i usually make people mad. thanks
|
This looks wrong to me...
while (numcheck = 0) shouldn't it be... while (numcheck == 0) |
Quote:
|
Maybe if you got with the program and didn't act like you have rice for gray matter, people wouldn't "get mad at you". You've certainly heard enough about the use of code tags. If you figure out a problem, as you say you did with IR's suggestion, post back so people won't continue to waste time on something you've fixed.
|
Yea man...do it again and your hands will be chopped off.
|
Quote:
:
std::cin.get(); |
easy solution
Are u using dev-c++ welll anyways just add this to the top of your file
#include <stdlib.h> and then use system("Pause"); // right before end of main example ****** #include <stdlib.h> #include <iostream.h> int main() { system("Pause"); return 0; } |
Bench's method is portable across systems, Eric's is not. The phenomenon, which is one of the most commonly asked questions about C/C++, is not Windows specific. Programs close when they finish. If you don't want them to finish before your eyeballs are through with the display, request user input. Deprive the program of that input until your eyeballs are through.
|
| All times are GMT -5. The time now is 9:14 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC