Ticker

6/recent/ticker-posts

C Language (strcmp function)

STRCMP FUNCTION IN C

The strcmp function is used to compare two string values.
It return 0, if both string values match exactly and return non zero value, if string values does not match.





STRCMP() FUNCTION EXAMPLE
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
clrscr();
char a[60], b[60];
int c;
puts("Enter first string value: ");
gets(a);

puts("Enter second string value: ");
get(b);

c=strcmp(a, b);
if(c==0)
{
printf("String values are same");
}
else
printf("String values are different");

getch();
}


----------------------------
         OUTPUT 
----------------------------

Enter first string value:
Computer

Enter second string value:
Computer

String values are different

























HOME

Post a Comment

0 Comments