hello i have last problem with strings i dunno whats wrong with this i dont get sometimes the logic coz when i write the program i do it into smaller stuff but this rlly string stuff drive me insane i hope i m gonna master it in the end anyways i have this function that its kinda like strcmp but it should return address like if i have two strings for example
"thats","hats" then it should return the beging where both strings matched till and it should count the num of where it doesnt match now i m lost in my function anyway here the code so far it totally suck but i m lost in coding this i think i complicate things more ....
#include <stdio.h>
#include <string.h>
int Check_Characters(char s1,char s2) {
if(s1==s2)
return 1;
return 0;
}
char * String_In(char *str,char *str1) {
int counter=0;//how many characters we found diffrent
int i;
int x=0;
char Temp[10];
int num=0;//variable to know which string are bigger to make loop run according for that
char *ptr;//used for returning will figure this out l8er
if(strlen(str) > strlen(str1))
num=strlen(str);
else
num=strlen(str1);
for(i=0; i< num ; i++) {
//do a first test first but with changing num to i like if for example some char matched and some then didnt match num wont be = to i but this will solve this problem
if(Check_Characters(str[i],str1[i])) {
num=i;
if(num==i){ //test first if num = to i to see if sequence of characters are =
num++;
puts("Dude it being runned");
Temp[x]=str[i];
i++;
}
}
}
puts(Temp);//to see if temp output
}
int main(void)
{
int x;
char temp[]="thats";
char temp2[]="hats";
String_In(temp,temp2);
return 0;
}