Quote:
How can I compare two numbers ?
.
The task I would understand in such a way that all inputs are read from a file. Here not the numbers, but the digits of the two numbers are to be compared. So it would be obvious to declare an array with minimum 4 digits and then check if there are matching digits. Since there can be several digits, these should be output in ascending order. It would therefore make sense to first collect all digits and then output them in the desired order. To process all lines in this way you need a loop that processes all lines. Your program so far contains still little for the solution, here a suggestion for starting:
FILE *fp = fopen("input.txt", "r");
if (fp == NULL) {
return -1;
}
char arr[13];
fgets(arr, sizeof(arr-1), fp);
int rows = atoi(arr);
if (rows <= 0) {
return -2;
}
int ch;
while ((ch = fgetc(fp)) != '\n');
fclose(fp);
If the two numbers are read in with scanf("%d %d", ..), you would have to calculate the digits for each number, so it would probably be easier to work directly with the digits from the text file.