C Programming Language Given the following program segment e
C Programming Language
Given the following program segment, explain what each of the two functions does. Show the results for two different pairs of input strings.Solution
#include<stdio.h>
int mystery1(char*, const char*);
void mystery2(char*, const char*);
int main(){
char string1[80],string2[80];
printf(\"Enter two Strings:\");
scanf(\"%s%s\",string1,string2);
prinf(\"\ First Result:\");
printf(\"%d\ \",mystery1(string1,string2));
prinf(\"\ Second Result:\");
mystery2(string1,string2);
printf(\"%s %s \ \",string1,string2);
getchar();
getchar();
return 0;
}
void mystery2(char *s1,const char *s2){
while(*s1!=\'\\0\')
++s1;
for(;*s1=*s2;s1++,s2++);
}
int mystery1(char *s1,const char *s2){
for(;*s1!=\'\\0\' && *s2!=\'\\0\'; s1++,s2++){
if(*s1!=*s2)
return 0;
return 1;
}
}
