I tried it under g++ V2.96 and it ran fine. The only thing I'd do is change the output line slightly:
cout << "Hello " << name << "!\n";
One problem you could have is that without the trailing "\n", the output buffer might not flush. In fact, a better way to prompt would be:
cout << "What is your name? ";
cout.flush();
Otherwise the prompt might not be forced out in time to be seen.
|