
318 Programming in C
Explanation:
In the above, two strings are compared up to the specified range. Their ASCII difference is
returned.
8.41 Write a program to demonstrate the use of memchr().
printf(“%d”,memcmp(sf,ss,2));
}
OUTPUT:
32
void main()
{
char *sf= “C IS EASY”;
clrscr();
printf(“%s”,memchr(sf,‘E’,10));
}
OUTPUT:
EASY
Explanation:
In the above program, the function memchr() searches for the first occurrence of ‘E’.
After getting the desired result, the remaining string is displayed.
8.7 applIcatIonS of StrIngS
8.42 Write a program to count a character that appears in a given text for a number of times. Use
the while loop. ...