problem with my input and output

Hello, Im using dev C++(i dont know if it matters or not) and every once in a while ill get this bug in the code with my input and output(cin/cout) i have the line of (using namespace std;) and im including the iostream and usuall a few others. can anyone tell me if there is something else that could go wrong with that i mean i have everything else typed in correctly and nothing else is wrong. for example i just got this problem from this line.
cout << x << endl;
if anyone has a soution or explination please let me know thanks.
this will work:

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
using namespace std;

int main()
{
int x; //   Maybe you did not Create the varible.  
cout<<"Enter a number\n";
cin>>x;  //Store what you entered into x (Only numbers, no lettters, no words)
cin.ignore(); //Dont count this time you press Enter.  (Dont close program)
cout<<"You entered: "<<x; // show what you entered as the number
cin.get();  //Wait until u press Enter, and then close
}


Hope that helps you. I think you may have forgot making the variable (int x;)
no i made the variable. but i added an extra end line on the end and it fixed im not sure why that made a diffrence.
Topic archived. No new replies allowed.