uses strncmp to compare two strings with the aid of the strlen function
#include <stdio.h>
#include <string.h>
main( )
{
char s1[]="Adam", s2[]="Abel";
int istringA_length,iresult=0;
istringA_length=strlen(s1);
if (strlen(s2) >= strlen(s1))
iresult = strncmp(s1,s2,istringA_length);
printf("The string %s found", iresult == 0 ? "was" : "wasn't");
return(0);
}
Related examples in the same category