diff --git a/ex5.3/main.cpp b/ex5.3/main.cpp index d0de438..15eb2c8 100644 --- a/ex5.3/main.cpp +++ b/ex5.3/main.cpp @@ -24,9 +24,6 @@ int main( int argc, char* argv[] ) { const int bufsize = 100; char buf[bufsize]; - const int linebufsize = 10; - char linebuf[linebufsize]; - // if EOF, fh returns false while( fh ) { fh.getline(buf, bufsize); @@ -36,10 +33,11 @@ int main( int argc, char* argv[] ) { std::istringstream line(buf); while( line ) { - linebuf[0] = '\0'; + std::string linebuf; + line >> linebuf; - if ( linebuf[0] != '\0' ) { + if ( ! linebuf.empty() ) { wordcount++ ; }