accept lines of text from the console and write the lines of text to the file. An empty string can be used to cause the program to quit accepting lines of text from the console and close the file. To test for an empty string (which occurs when you press the Enter key without typing any text),use the strlen() function from the string.h include file. Is this how it's supposed to look?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str;
cout << "Enter string for testing "
<< "(0 to quit) : ";
while ( cin >> str )
{
cout << endl;
cout << "String is : " << str << endl;
cout << "Enter string for testing "
<< "(0 to quit) : ";
}
if ( str = 0)
{
cout <<"The End" << endl;
break;
}
return 0;
}

New Topic/Question
Reply




MultiQuote







|