Question: How do I get the C program to scan the information in a .txt file and arrange it in a new .txt file? I have

How do I get the C program to scan the information in a .txt file and arrange it in a new .txt file? I have been trying to do this with fprintf and fscanf but I haven't figured out how to arrange it correctly.

#include

#include

#define ITEMS 51

int i;

int s;

int main(void)

{

FILE* costs = fopen("Costs.txt", "r");

FILE* total_sales = fopen("Total_sales.txt", "w");

int totalSalesArray[2][50]= {{},{}};

for (int i = 0; i < 2; i++) //outer loop

{

for (int s = 0; s < 50; s++) // inner loop

{

printf("%d", totalSalesArray[i][s]);

}

printf(" ");

}

fprintf(total_sales, "%d", totalSalesArray[i][s]); //write two lines

fclose(total_sales);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!