News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Using strcasecmp

Started by jin_yeugh, April 29, 2013, 07:11:34 PM

Previous topic - Next topic

jin_yeugh

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

frankie

"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

TimoVJL

#2
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())
May the source be with you

jin_yeugh

Thanks, guys!  _stricmp works swimmingly