Comparing 2 Strings in C
I am trying to create a program which will compare 2 strings.Find the first character which is equal between them and save it on the third string.If it doesnt find any character it will save a -1.
My code always prints a -1... :(
Here is my code,I dont know what I am doing wrong.If anybody has any idea,plz help me.
#define MAX 1000
void any(char s1,char s2,char s3);
printf("Jepni stringen 1\n");
scanf("%s",& string1); //saving string 1
printf("Jepni stringen 2\n");
scanf("%s",& string2); //saving string 2
any(string1,string2,string3); /*comparing characters from string 2 to string 1 and saving the places where they are equal on third string*/
printf("%d",string3); //printing the first character of the third string
void any(char s1,char s2,char s3)
Found The answer should have put s2[j] and s1[i] are diferrent from \0.