i have made some code but i stops after first string it it doesnt chk the others
#include <stdio.h>
#include <ctype.h>
char * String_Within(char *str1,char *str2) {
char temp[50];
int i,x=0;
int z=0;
int num=0;
/*first of all lets run in a double for loop and each time will be less than the certain num */
/*that certain num will have to know when the space is there and 2nd time is run we += it so it doesnt stop at that space again */
//first of all lets read in nested loop
for( i=x ; str1[i]!=0 ; i++ ) {
for( x=num ; str2[x]!=0; x++ ) {
num++;
//we will keep incrementing num
if(str2[x]==str1[i]) {
temp[z]=str1[i];
z++;
}
if(isspace(str2[x])) {
num+=1;//start at the stuff after the space
break;
}
else
break;
}
temp[z]=' ';//add a space to the character we have atm
}
temp[z]='\0';//to put null character
puts(temp);
//we gonna return it later now
}
int main(void)
{
char Name[]="thats good a coder";
char Name1[]="thats good a dog";
char *ptr;
ptr=String_Within(Name,Name1);
//will figure out rest of code later
return 0;
}
it only got thats then a O .... and it should be counting the 2nd string in the char which is good which is right too ... once i solved this i guess then i can easily compare temp to str and extract the chars that arent same and return it to main function and change str to temp