PDA

View Full Version : c++ problems running programs with cout


java2
02-04-2006, 08:11 PM
just downloaded the dev C++ program. the pograms compile fine wihout any problems but when i run them the program closes when it reaches a "cout".

strangely the "cin" works fine so my guess is that its not a problem with the header.



#include <iostream>
#include <string>
using namespace std; int main()
{
string name; int ID; cout << "Enter your name ";
cin >> name;
cout << "Enter your ID number ";
cin >> ID;
cout << "Hello " << name << " or should I say " << ID << endl;
return 0;
}


Thanks in advance

eak
02-04-2006, 08:15 PM
that is normal behavior. after the program finishes, it closes. to prevent this, you can do another cin or a getChar before you return 0.