1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
// string::clear
#include <iostream>
#include <string>
int main ()
{
char c;
std::string str;
std::cout << "Please type some lines of text. Enter a dot (.) to finish:\n";
do {
c = std::cin.get();
str += c;
if (c=='\n')
{
std::cout << str;
str.clear();
}
} while (c!='.');
return 0;
}
| |