diff --git a/ex5.3/main.cpp b/ex5.3/main.cpp index 1d8ea50..d0de438 100644 --- a/ex5.3/main.cpp +++ b/ex5.3/main.cpp @@ -36,8 +36,13 @@ int main( int argc, char* argv[] ) { std::istringstream line(buf); while( line ) { + linebuf[0] = '\0'; line >> linebuf; - wordcount++ ; + + if ( linebuf[0] != '\0' ) { + wordcount++ ; + } + if ( line.eof() ) { @@ -48,5 +53,5 @@ int main( int argc, char* argv[] ) { } - std::cout << " " << linecount-1 << " " << wordcount-1 << " " << charcount-1 << " " << argv[1] << std::endl; + std::cout << " " << linecount-1 << " " << wordcount << " " << charcount-1 << " " << argv[1] << std::endl; }