Sunday, 15 February 2015

strcmp and strcmpi

Compare Two Strings

Sometimes you want to determine if two strings are the same. For this we have the strcmp function.
int strcmp(string1, string2);

Compare Two Strings (Not Case Sensitive)

If you do not care whether your strings are upper case or lower case then use this function instead of the strcmp function. Other than that, it’s exactly the same.
 printf("%d", strcmp(fname, lname));
 
Note:stricmp is Windows-specific.
If you're not on Windows, strcasecmp 

0 comments:

Post a Comment