#include <iostream>
usingnamespace std;
int main()
{
shortint x;
cin >> x;
cout<<"X variable: " << x << "\n";
cout<<"Memory Address of x: " << &x << "\n";
cin.get();
}
Program gets to cin >> x; then quits after input is given. Why is this happening? I know it has to do with the way I'm inputting integer x but I can't quite put my finger on it.
...Yes, but it is standard C and C++. Functions that have a non-void return type should have a return statement -- programmers expect to see one. It doesn't take that much just to type it in, and your code won't break on anyone's machine.
Between lines 8 and 9 you need to clear all input to the end of the line. Add 8.5cin.ignore( numeric_limits <streamsize> ::max(), '\n' );