strncmp function in c

strncmp function compares only specified number of characters

syntax:

strcmp(string 1,string 2,n);

#include
#include
main()
{
char s1[20],s2[20];
int n;
printf("\nEnter String1:");
gets(s1);
printf("\nEnter String2:");
gets(s2);
n= strncmp(s1,s2,5);
if(n==0)
printf("\nStrings are Same up to 5 Characters");
else
printf("\n NOT SAME");
}