/**1* Exercise 2.52*3* Write the function any(s1,s2) which returns the first location in the string4* s1 where any character from the string s2 occurs, or -1 if s1 contains5* no characters from s2. ( The standard library function strpbrk does6* the same job but retuns a pointer to the location7*8**/910#include<stdio.h>11#define MAXLINE 10001213int mgetline(char line[],int maxline);14int any(char s1[],char s2[]);1516int main(void)17{18char s1[MAXLINE],s2[MAXLINE];19int val;2021/* Give the first string s1 */2223mgetline(s1,MAXLINE);2425/* Give the second string s2 */2627mgetline(s2,MAXLINE);2829val = any(s1,s2);3031printf("%d",val);3233return 0;34}3536int mgetline(char s[],int lim)37{38int i,c;39for(i=0;i<lim-1 && (c=getchar())!=EOF && c!='\n';++i)40s[i]=c;4142if(c=='\n')43s[i++]=c;44s[i]='\0';45}464748int any(char s1[],char s2[])49{50int i,j;5152for(i=0;s1[i]!='\0';++i)53{54// iterate through s2 while trying to find matching character from s155for(j=0;(s1[i]!=s2[j]) && s2[j]!='\0';++j)56; // continue5758if(s2[j]!='\0' && s2[j] != '\n') { // check that s2 [j]! = '\n', since s1 and s2 both have the character '\n' in the penultimate position of the string.59return i;60}61}6263return -1;64}6566