wordcountiterator

#include <iostream>

#include <sstream>

#include <string>

#include <iterator>

//http://www.linuxquestions.org/questions/programming-9/c-counting-words-in-a-string-173787/

using namespace std;

/*

int main()

{

string msg;

cout << "Type in a string\n";

getline(cin, msg);

istringstream ostr(msg);

istream_iterator<string> it(ostr);

istream_iterator<string> end;

size_t words = 0;

while (it++ != end) words++;

cout << "\nThere are " << words << " words in this string." << endl;

cin.ignore();

return 0;

}

*/

Popular posts from this blog

ch11 review silberschatz operating systems concepts essentials 2nd ed