So I'm pretty new to C/C++ but have experience with a lot of Java. Basically I'm trying to make a prompt in the terminal that will take the user input and add it to a string array. I'm writing the program in C++ but will eventually have to use the c_str() function to generate a c-style array of chars.
Anyway, before all that, I'm having a problem with one little thing. The prompt for user input is going to be issued until "exit" is typed. If nothing is typed and just enter is pressed I want it to go to the new line and issue "prompt:" again but I'm not sure on the right way to do that. This way does not work and seems to enter some sort of infinite loop.
Anyway, before all that, I'm having a problem with one little thing. The prompt for user input is going to be issued until "exit" is typed. If nothing is typed and just enter is pressed I want it to go to the new line and issue "prompt:" again but I'm not sure on the right way to do that. This way does not work and seems to enter some sort of infinite loop.
string input;
cout << "[ prompt: ] ";
while (input != "exit")
{
getline(cin, input);
if (input == "\n")
{
cout << "[ prompt: ] ";
}
}