home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / microcrn / issue_44.arc / MICROCAD.ARC / WIDTH.CPP < prev   
C/C++ Source or Header  |  1988-08-05  |  615b  |  25 lines

  1. // file: width.cpp
  2. // checks source code width for publication
  3. #define MAXWIDTH 50
  4. #include <stream.hpp>
  5. #include <string.h>
  6.  
  7. main() {
  8. char line[100], * lp;
  9. char c;
  10. int count = 0;
  11. int width;
  12. while(cin.good()) {
  13.     lp = line;
  14.     while ( cin.get(c), cin.good() && c != '\n')
  15.         *lp++ = c;  // get a whole line
  16.     *lp = 0; // null terminate
  17.     count++;  // count the line
  18. //    cout << count << ": " << line << "\n";
  19.     width = strlen(line);
  20.     if ( width > MAXWIDTH) {
  21.         cout << "line " << count << " too wide by "
  22.             << width - MAXWIDTH << " characters\n";
  23.     }
  24. }}
  25.