Hi all
Any help would be much appreciated.
Im following the about.com tutorial, and one of the exercises says i should make this program;
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string name;
int ID;
cout<<"enter your name\n";
cin>> name;
cout<<"enter your id\n";
cin>> ID;
cout <<"hello" <<name <<", or should i say" <<ID <<endl;
return 0;
}
It compiles fine; when I run it, it asks me for my name, and then id, but when i press return it just closes the window.
Ive tried adding in a cin.get()
, which resolved the problem with the hello world programme i did, but not this.
I dont understand why it wont display the text afterwards?!?
Help please for my sanity (why dont think work like on the tutorials - did people try out the programmes before putting them on?)
P.S As a an afterfthough what purpose does the endl
tag serve? it doesn't seem to make a difference.