/* strcmp() function defination in c */
int myStrCmp(const char *s1, const char *s2)
{
while (*s1==*s2)
{
if(*s1=='\0')
return(0);
s1++;
s2++;
}
return(*s1-*s2);/*an integer greater than, equal to, or less than 0, if the string pointed to by s1 is greater than, equal to, or less than the string pointed to by s2, respectively.*/
}
/* const keyword : is used so that the data pointed by s1 and s2 remains unchanged and if any statement tries to modifie it ,then the compiler will post an error so in order to safe guard some information which we expect to be unchaged we declare it with the key word const */
No comments:
Post a Comment