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

  1.  /* The strcmp() function. */
  2.  
  3.  #include <stdio.h>
  4.  #include <string.h>
  5.  
  6.  main()
  7.  {
  8.      char str1[80], str2[80];
  9.      int x;
  10.  
  11.      while (1)
  12.      {
  13.  
  14.          /* Input two strings. */
  15.  
  16.          printf("\n\nInput the first string, a blank to exit: ");
  17.          gets(str1);
  18.  
  19.          if ( strlen(str1) == 0 )
  20.              break;
  21.  
  22.          printf("\nInput the second string: ");
  23.          gets(str2);
  24.  
  25.          /* Compare them and display the result. */
  26.  
  27.          x = strcmp(str1, str2);
  28.  
  29.          printf("\nstrcmp(%s,%s) returns %d", str1, str2, x);
  30.      }
  31. }
  32.