Thursday, March 3, 2016

strcmp() function example in C

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include<stdio.h>
#include<string.h>

main()
{
 char name[20],name2[20];
 int value;
 printf("Enter your name ?\n");
 gets(name);
 printf("Enter name2?.\n");
 gets(name2);
 value = strcmp(name,name2);
 if(value==0){
  printf("The strings are equal.");
 }
 else printf("not");
}

No comments:

Post a Comment

Thank you for commenting. Please wait for response :)