strcmp

Navigation:  Programming language SQC > Libraries > String manipulation >

strcmp

Previous pageReturn to chapter overviewNext page

The strcmp() function compares two strings.

It returns a 0 if both strings are equal, and nonzero otherwise.

The comparison is case-sensitive.

 

int strcmp(char *str1,char* str2)

 

Example:
 
void main()

{

  char str1[20] = "Hello World";

 

  if( strcmp(str1,"Hello World")==0)

  {

     printf("Strings match");

  }

}

 

Output:

 

  Strings match