oh yhea!
I think I got it!
maybe someone will make me SQA :P
Code:
#include <stdio.h>
#define INPUT_LEN 256
int findWord(char arr[], char word[]);
int compareArray(char arr1[],char arr2[],int pos1,int pos2);
int checkArray(char arr[],int pos);
void main(){
char word1[INPUT_LEN]={0},word2[INPUT_LEN]={0};
printf("Enter first string:\n");
gets(word1);
printf("Enter second string:\n");
gets(word2);
printf("Output:\n");
printf("%d\n\n",findWord(word1,word2));
}
int findWord(char arr[], char word[]){
if (compareArray(arr,word,0,0)<checkArray(arr,0))
return compareArray(arr,word,0,0);
else
return 0;
}
int compareArray(char arr1[],char arr2[],int pos1, int pos2){
if (arr1[pos1]==0||arr2[pos2]==0) return 0;
if (arr1[pos1]== arr2[pos2])
return (compareArray(arr1,arr2,pos1+1,pos2+1)+1);
else
return (compareArray(arr1,arr2,pos1+1,pos2)+1);
}
int checkArray(char arr[],int pos){
if (arr[pos]==0) return 0;
return (checkArray(arr,pos+1)+1);
}