home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / Libraries / Str / c / stricmp < prev    next >
Encoding:
Text File  |  1994-05-29  |  1.0 KB  |  39 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Str.stricmp.c
  12.     Author:  Copyright © 1994 Tim Browse
  13.     Version: 1.00 (06 Mar 1994)
  14.     Purpose: Case-insensitive version of strcmp
  15. */
  16.  
  17. #include "Str.h"
  18. #include <ctype.h>
  19.  
  20. int stricmp(char *s1, char *s2)
  21. {
  22.   char ch1 = 0, 
  23.        ch2 = 0;
  24.  
  25.   for(;;)
  26.   {
  27.     if ((*s1 == 0) && (*s2 == 0))
  28.       return 0; /* s1 and s2 are equal */
  29.       
  30.     ch1 = toupper(*s1);
  31.     ch2 = toupper(*s2);
  32.  
  33.     if (ch1 != ch2)
  34.       return (int) (ch1 - ch2);
  35.     s1++;
  36.     s2++;
  37.   }
  38. }
  39.