home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_07
/
1107107b
< prev
next >
Wrap
Text File
|
1993-05-04
|
542b
|
28 lines
// 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))
{
++lc;
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