int main(void)
{
int operations, i, operands;
char *string_dig1, *string_dig2;
// OPEN THE FILE
FILE *ifp;
ifp = fopen("bigint.txt", "r");
fscanf (ifp, "%d", &operations);
printf("%d\n", operations);
// MAKE MEMORY TO READ THE STRING DIGITS INTO THE ARRAY
string_dig1 = (char *)malloc(sizeof(char));
string_dig2 = (char *)malloc(sizeof(char));
for(i = 0; i <= operations; i++)
{
fscanf(ifp, "%d %s %s", &operands, string_dig1, string_dig2);
printf("%d\n %s %s", operands, string_dig1, string_dig2);
}
fclose(ifp);
system ("pause");
return 0;
}
ive been trying to print the contents of the file. but its giving me wrong output.. this is the original
------------------------------------------------
3
1 8888888888 2222222222
2 9999999999 10000000000
2 10000000000 9999999999
--------------------------------------
i want to replicate it in the output screen but this is what it is giving me
----------------------------------------------------------
3
8888888888 2222222222
9999999999 100000000002
10000000000 99999999992
--------------------------------------------------------
1st line contains the number that represents number of operations,after that each line contains 3 digits. 1 and 2 represents addition and subtraction operands. next two are integers that should be read in as array of digits