My current code seems to work fine on DOS but not on Unix, and I need to make it work on both. From what I have found so far, it seems I should use strtol(). However, I cannot seem to figure out how to get strtol() to get only the first two integers.
The input is a text file that looks like this:
45x7
(1,0)
(10,2)
And I need the output to be "There are 45 rows and 7 columns."
This is my current code:
int rows=0, columns=0;
scanf("%d%*c%d%*c", &rows, &columns);
printf("There are %d rows and %d columns.", rows, columns);
return 0;
I do not want to discard the remaining text file as I will need to process that as well.