I wrote a little test program to try to figure out some problems I am having in another program I'm working on.
Code:
# include <iostream>
# include <string>
using namespace std;
void ahoy(string nameEntered)
{
cout << "Ahoy, " << nameEntered << "!" << endl;
}
int main()
{
string name;
cout << "enter your name: ";
getline(cin, name);
ahoy(name);
return 0;
}
I am using Visual C++ 6.
Problem 1: After I enter keyboard input I have to press enter twice. Why not once? I see this both when I am testing the program in the editor, and also when I run the .exe.
Problem 2: In the .exe, the window closes so I never see the output from the function. How can I make it pause?
I haven't dealt with C++ in a couple of years so I may have just forgotten some simple things.