Listing 11 Reads words from a string stream

// lwc.cpp: Display count of lines and words
#include <iostream.h>
#include <strstream.h>
#include <stddef.h>

main()
{
   const size_t BUFSIZ = 128;
   char s[BUFSIZ];
   size_t lc = 0, wc = 0;

   while (cin.getline(s,BUFSIZ))
   {
      ++1c;
      istrstream line(s);
      char word[BUFSIZ];
      while (line >> word)
         ++wc;
   }

   cout << "Lines: "<< lc << ", words: "<< wc << endl;
   return 0;
}

// Output from the statement "lwc < lwc.cpp"
// Lines: 24, words: 63

// End of File