home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / tyc / list17_1.c < prev    next >
C/C++ Source or Header  |  1993-10-16  |  432b  |  24 lines

  1.  /* Using the strlen() function. */
  2.  
  3.  #include <stdio.h>
  4.  #include <string.h>
  5.  
  6.  main()
  7.  {
  8.      size_t length;
  9.      char buf[80];
  10.  
  11.      while (1)
  12.      {
  13.          puts("\nEnter a line of text; a blank line terminates.");
  14.          gets(buf);
  15.  
  16.          length = strlen(buf);
  17.  
  18.          if (length != 0)
  19.              printf("\nThat line is %u characters long.", length);
  20.          else
  21.              break;
  22.      }
  23.  }
  24.