Originally posted by: Gamingphreek
	
	
		
		
			Originally posted by: Pantlegz1
	
	
		
		
			Originally posted by: Gamingphreek
	
	
		
		
			Originally posted by: aznium
	
	
		
		
			Originally posted by: Gamingphreek
	
	
		
		
			Originally posted by: aznium
	
	
		
		
			Originally posted by: Pantlegz1
yes I hit enter and the window closes.
Sorry, but I don't understand what you mean by not flushing the input buffer. How could I resolve this? I've kept working and I ran into a similar issue with this code...
int main()                            /* Most important part of the program!
*/
{
    int age;                          /* Need a variable... */
  
    printf( "Please enter your age" );  /* Asks for age */
    scanf( "%d", &age );                 /* The input is put in age */
    if ( age < 100 ) {                  /* If the age is less than 100 */
     printf ("You are pretty young!\n" ); /* Just to show you it works... */
  }
  else if ( age == 100 ) {            /* I use else just to show an example */ 
     printf( "You are old\n" );       
  }
  else {
    printf( "You are really old\n" );     /* Executed if no other statement is
    */
  }
  return 0;
}
I enter a number, press enter and the window just closes.
		
		
	 
Two options
1) add another scanf or getchar() to read another char before closing the window
2) open a dos / powershell window and launch your exe through there, your console won't close right away
		
 
		
	 
Just use a cin.get() command for C++.
-Kevin
		
 
		
	 
cin.get is for C++, he's using printf and scanf ... so only right to follow it up with a getchar or another scanf
		
 
		
	 
He said it is C++, so it certainly wouldn't hurt anything.
As for the headers, I honestly don't see any logical reason why the "stdafx.h" header is included as printf and scanf should all be in the "stdio.h" header. There is no need to include everything that stdafx covers.
OP, if you are doing C++, you should be using the C++ overload I/O commands:
#include <iostream.h>
using namespace std;
void main()
{
int theNumber = 0;
cout << "Please enter a number" << endl;
cin >> theNumber;
cout <<  "You entered " << theNumber << endl;
cin.get();
return;
}
Right now you are using std C commands.
-Kevin
		
 
		
	 
 
Well this caused all sorts of problems... first and most confusing for me was "Warning	1	warning C4627: '#include <iostream.h>': skipped when looking for precompiled header"
why would it skip that? I also got an error saying that sdtafx.h wasn't included, why does it insist on using that header?
I think the errors that follow are issues with iosteam.h not being included. cout, cin and end1 are 'undeclared identifiers' and "left of '.get' must have class/struct/union" 
Needless to say I'm confused as hell right now 
		 
		
	 
The bad thing is, it is all my fault for not explaining that code (and for not thinking before I typed).
First off, it is #include <iostream>
The .h is not necessary when using brackets with standard libraries.
That will solve cout, cin.
Next off (You are gonna laugh at this one), that is not an end1, it is an endl (L). 
See if that solves all of your problems - it should in my mind. As for stdafx error, that is certain weird. I don't have VS2008 in front of me or I would see what I can dig up on that.
At any rate, see if my corrections fix all my problems.