home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / xv221src / docs / longline.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-24  |  742 b   |  31 lines

  1. /* finds out how long the longest line in a file is
  2.  *
  3.  * necessary because dopey Mac laserwriter driver (6.0) generates 
  4.  * lines longer than 255 characters in the xvdocs.ps file.  This exceeds the
  5.  * postscript spec, and no doubt breaks on some printers, hence I have to
  6.  * make sure that there are no long lines when I distribute said PS file.
  7.  *
  8.  *   --jhb, 4/24/92
  9.  */
  10.  
  11.  
  12. #include <stdio.h>
  13.  
  14. main()
  15. {
  16.   int c, longest, count;
  17.  
  18.   longest = count = 0;
  19.  
  20.   while ((c=getchar()) != EOF) {
  21.     if (c == '\n') {
  22.       if (count>longest) longest = count;
  23.       count = 0;
  24.     }
  25.     else count++;
  26.   }
  27.  
  28.   if (count>longest) longest = count;
  29.   printf("Longest line is %d chars long, not counting the NL\n", longest);
  30. }
  31.