1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aksik [14]
3 years ago
15

Open the"stateData3.c" program and try to understand how the tokenization works. If you open the input file "stateData.txt", you

can clearly seethat a comma separates the state name and its population. The tokenizer portion of the programs separates each line into two tokens and stores them into two different arrays. You need to display the arrayelements such that each line has a state and itspopulation. Also calculate the total population of USA.Then,examine the portion of the code how it writes the array elements into a binary datafile.You need to write similar logic where it writes the array elements into a text file "stateDataOutput2.txt". Please check the syntax and usage of fprintf(); and use that here.
Engineering
1 answer:
babymother [125]3 years ago
5 0

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;

}

You might be interested in
An array of electronic chips is mounted within a sealedrectangular enclosure, and colling is implemented by attaching analuminum
Licemer1 [7]

Answer:

Base temperature is 46.23 °C

Explanation:

I've attached explanations

6 0
3 years ago
I don't know what is this​
pychu [463]
That means “ if possible then link”
8 0
3 years ago
What does this map show about the Viking civilization?
BlackZzzverrR [31]

Answer:

the answer is c

Explanation:

8 0
3 years ago
Read 2 more answers
Which 1 of the following did women NOT do during WWII?
Anastaziya [24]

Answer:

Didn't do what, there are no women as answers. Contact me and give me the women.

Explanation:

3 0
3 years ago
Read 2 more answers
What should be your strongest tool be for gulding your ethical decisions making process
valkas [14]

Answer:

Recognize that there is a moral dilemma.

Determine the actor. ...

Gather the relevant facts. ...

Test for right versus wrong issues. ...

Test for right versus right paradigms. ...

Apply the resolution principles. ...

Investigate the trilemma options. ...

Make the decision.

7 0
2 years ago
Other questions:
  • What is the difference between absolute and gage pressure?
    11·1 answer
  • Short-term memoryA) has a larger storage capacity than long-term memory.B) takes longer to retrieve than long-term memory.C) inv
    9·1 answer
  • When using levers like scissors or hedge clippers, what can be done to increase the cutting force so that you don’t have to sque
    5·1 answer
  • How do people eat with there noses shut
    12·2 answers
  • The following passage contains a fragment. Select the correct revision. Presley took the exuberance of gospel and added the freq
    7·1 answer
  • Describe the make-up of an internal combustion engine.<br> Pls answer quickly.
    5·1 answer
  • A misfire code is a type ____ DTC<br> A) 1 or 2<br> B) a or b<br> C) c or d<br> D l or ll
    15·1 answer
  • What are the main causes of injuries when using forklifts?
    5·1 answer
  • The pressure less than atmospheric pressure is known as:
    6·1 answer
  • Flip-flops are normally used for all of the following applications, except ________. logic gates data storage frequency division
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!