I'm going to identify the difference between two string. I can't see what I'm missing here. The output from my code is correct by the sample. But when I test run it with other test, it fails. I can't see what the other tests are.
The input:
The first line of input contains an integer 1<= n <= 500, indicating the number of test cases that follow. Each test case is a pair of lines of the same length, 1 to 50 characters. Each string contains only letters (a-z,A-Z) or digits (0-9).
The Output:
For each test case, output the two lines in the order they appear in the input. Output a third line indicating similarities and differences as described above. Finally, output a blank line after each case.
Sample:
int main()
{
int n;
// scan the integer for number of test cases
if(scanf("%d", &n) != 1) {
return 1;
}
//Loop through the test cases
for (int i = 0; i < n; i++)
{
char string1[1024], string2[1024], output[50];
//Scan first and second string
if(scanf("%s", string1) != 1) {
return 1;
}
if(scanf("%s", string2) != 1) {
return 1;
}
//Loop through the strings and compare them
for (int i = 0; string1[i] != '\0' || string2[i] != '\0'; i++)
{
//Convert to lowercase
string1[i] = tolower(string1[i]);
string2[i] = tolower(string2[i]);
//Compare
if (string1[i] == string2[i])
{
output[i] = '.';
} else {
output[i] = '*';
}
}
//Print the strings and the output.
printf("%s\n%s\n%s\n", string1, string2, output);
if(i + 1 < n) {
printf("\n");
}
}
return 0;
}

