Mega Code Archive
Categories
/
C++ Tutorial
/
String
Use cin in while loop to read string
#include
#include
using namespace std; int main() { int count = 0; string word; while (cin >> word) { count++; } cout << count << " words.\n"; return 0; }