Pelles C forum

C language => Beginner questions => Topic started by: jin_yeugh on April 29, 2013, 07:11:34 PM

Title: Using strcasecmp
Post by: jin_yeugh on April 29, 2013, 07:11:34 PM
I'm having trouble finding a function to use which compares two strings, disregarding case.
this is the simple program I'm trying to use the strcasecmp function in and, obviously, strcasecmp isn't recognized as a function. I just left it into show how I hope to use the function or it's equivalent

//String compare
#include<stdio.h>
#include<string.h>

int main(void)
{
   char string[16];
   char password[] = "please";
   int result;

   printf("Enter your secret password:\n");
   gets(string);

   result = strcasecmp(string,password);

   if (result==0)
      puts("Entry granted!");
   else
      puts("Sorry. Wrong password.");


   printf("\n\n\n");
   return(0);
}

Thanks
Title: Re: Using strcasecmp
Post by: frankie on April 29, 2013, 07:20:11 PM
use _stricmp
Title: Re: Using strcasecmp
Post by: TimoVJL on April 29, 2013, 07:48:56 PM
If  case sensitive, use compiler option -Go, Define compability names for that function.
It is just missing from header-file <string.h>
If you are ignoring case, use _stricmp (or strncasecmp())
Title: Re: Using strcasecmp
Post by: jin_yeugh on May 09, 2013, 08:38:56 PM
Thanks, guys!  _stricmp works swimmingly