Answer:
Kindly see explaination
Explanation:
Code
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define size 200
int main(void)
{
int const numStates = 50;
char tempBuffer[size];
char tmp[size];
char fileName[] = "stateData.txt"; // Name of the text file (input file) which contains states and its populations
char outFile[] = "stateDataOutput1.txt"; // Output file name
// Open the input file, quit if it fails...
FILE *instream = fopen(fileName, "r");
/* Output File variable */
FILE *opstream;
if(instream == NULL) {
fprintf(stderr, "Unable to open file: %s\n", fileName);
exit(1);
}
//TODO: Open the output file in write ("w") mode
/* Opening output file in write mode */
opstream = fopen(outFile, "w");
//TODO: Read the file, line by line and write each line into the output file
//Reading data from file
while(fgets(tmp, size, instream) != NULL)
{
//Writing data to file
fputs(tmp, opstream);
}
// Close the input file
fclose(instream);
//TODO: Close the output file
/* Closing output file */
fclose(opstream);
return 0;
}