NO

Author Topic: Using strcasecmp  (Read 3468 times)

jin_yeugh

  • Guest
Using strcasecmp
« 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

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Using strcasecmp
« Reply #1 on: April 29, 2013, 07:20:11 PM »
use _stricmp
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Using strcasecmp
« Reply #2 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())
« Last Edit: April 29, 2013, 07:58:19 PM by timovjl »
May the source be with you

jin_yeugh

  • Guest
Re: Using strcasecmp
« Reply #3 on: May 09, 2013, 08:38:56 PM »
Thanks, guys!  _stricmp works swimmingly