xxxxxxxxxx
#include <stdio.h>
#include <string.h>
int main()
{
char s1[20] = "BeginnersBook";
char s2[20] = "BeginnersBook.COM";
if (strcmp(s1, s2) ==0)
{
printf("string 1 and string 2 are equal");
}else
{
printf("string 1 and 2 are different");
}
return 0;
}
xxxxxxxxxx
return
>0 if first string is large
<0 if first string is short
0 if strings are equal
int strcmp ( const char * str1, const char * str2 );
strcmp
xxxxxxxxxx
strcmp("abb", "abc"); /* = -1 */
strcmp("abc", "abd"); /* = 1 */
strcmp("abc", "abc"); /* = 0 */