// Input an array s that stores 5 strings of maximum size 10. Input another string // t from the user of maximum size 5. Assume that the strings do not contain any // blank or whitespace character. // // Write a function that finds the index of first occurrence of substring t in // each string of s. If the substring is not found, it returns -1. Write another // function that returns an integer array of size 5 // Author: rahule@cse.iitk.ac.in #include #include int *substring(char s[][10],char t[10]); int string_length(char *); main() { char s[5][10],t[10]; int i,op[5],*p; //enter s and t printf("\nEnter 5 strings\n"); for(i=0;i<5;i++) scanf("%s",s[i]); printf("\nEnter the string to be searched for :"); scanf("%s",t); //call the function that would return the required array p=substring(s,t); //print the returned array contents for(i=0;i<5;i++) printf(" %d",*(p++)); printf("\n"); } int *substring(char s[][10],char t[10]) { int i,flag,k,*op,j; op=malloc(5*sizeof(int)); //creates an array op[5] to store the output for(i=0;i<5;i++) //for each string in s,do { op[i]=-1; //initialize op[i]=-1 for(j=0;j< (string_length(s[i]) - string_length(t)) ;j++) //for each s[i][j] do...(note that j value only moves till length(s[i]) - length(t) { flag=0; //flag = 0 .implies,s[i] dont have a substring t till now for(k=0;k