#include <iostream>
#include <string>
using namespace std;
int main(void)
{
string text;
do
{
cout << "prompt: ";
getline(cin, text);
} while ( text[0] == '\0' );
cout << "text = " << text << endl;
return 0;
}
/* my output
prompt:
prompt:
prompt:
prompt: hello world
text = hello world
*/
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
string text("text"), response(text);
do
{
cout << "prompt <" << text << "> : ";
getline(cin, response);
} while ( response[0] == '\0' );
text = response;
cout << "text = " << text << endl;
return 0;
}
/* my output
prompt <text> :
prompt <text> :
prompt <text> : hello
text = hello
*/
Reputation Points: 2780
Solved Threads: 312
long time no c
Offline 4,790 posts
since Apr 2004