Listing 3 Counts the words in a text file

// wc.cpp: Display word count
#include <iostream.h>
#include <stddef.h>

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

   while (cin >> s)
      ++wc;

   cout << wc << '\n';
   return 0;
}

// Output from the command "wc<wc.cpp"
//35

// End of File