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
boyakko [2]
3 years ago
13

Define a structure type auto_t to represent an automobile. Include components for the make and model (strings), the odometer rea

ding, the manufacture and purchase dates (use another user-defined type called date_t), and the gas tank (use a user-defined type tank_t with components for tank capacity and current fuel level, giving both in gallons). Write I/O functions scan_date, scan_tank, scan_auto, print_date, print_tank, and print_auto, and also write a driver function that repeatedly fills and displays an auto structure variable until EOF is encountered in the input file.
Computers and Technology
1 answer:
yulyashka [42]3 years ago
8 0

Answer:

see explaination

Explanation:

#include <stdio.h>

#include <string.h>

#define BUFSIZE 1000

struct auto_t scan_auto(char *);

struct date_t {

char day[2];

char month[2];

char year[4];

};

struct tank_t {

char tankCapacity[10];

char currentFuelLevel[10];

};

struct auto_t {

char make[50];

char model[50];

char odometerReading[10];

struct date_t manufactureDate;

struct date_t purchaseDate;

struct tank_t gasTank;

};

int main(int argc, char *argv[]) {

/* the first command-line parameter is in argv[1]

(arg[0] is the name of the program) */

FILE *fp = fopen(argv[1], "r"); /* "r" = open for reading */

char buff[BUFSIZE]; /* a buffer to hold what you read in */

struct auto_t newAuto;

/* read in one line, up to BUFSIZE-1 in length */

while(fgets(buff, BUFSIZE - 1, fp) != NULL)

{

/* buff has one line of the file, do with it what you will... */

newAuto = scan_auto(buff);

printf("%s\n", newAuto.make);

}

fclose(fp); /* close the file */

}

struct auto_t scan_auto(char *line) {

int spacesCount = 0;

int i, endOfMake, endOfModel, endOfOdometer;

for (i = 0; i < sizeof(line); i++) {

if (line[i] == ' ') {

spacesCount++;

if (spacesCount == 1) {

endOfMake = i;

}

else if (spacesCount == 2) {

endOfModel = i;

}

else if (spacesCount == 3) {

endOfOdometer = i;

}

}

}

struct auto_t newAuto;

int count = 0;

for (i = 0; i < endOfMake; i++) {

newAuto.make[count++] = line[i];

}

newAuto.make[count] = '\0';

count = 0;

for (i = endOfMake+1; i < endOfModel; i++) {

newAuto.model[count++] = line[i];

}

newAuto.model[count] = '\0';

count = 0;

for (i = endOfModel+1; i < endOfOdometer; i++) {

newAuto.odometerReading[count++] = line[i];

}

newAuto.odometerReading[count] = '\0';

return newAuto;

}

You might be interested in
What item on a business card is generally the most prominent?
AveGali [126]
The most prominent
Company name that's most important
3 0
3 years ago
Read 2 more answers
Can someone let me join your kingdom if anybody knows this game and plays it as well. ​
Assoli18 [71]

Answer:

sure is called voxetas

Explanation:

7 0
3 years ago
What category of predefined formulas in Excel contains the Boolean functions?
ololo11 [35]
The predefined formulas in Excel that contain the Boolean functions fall under the Logical Functions category. The Boolean functions consist of "AND", "OR", "XOR", "NOT", "IF", "IFERROR" and "IFNA".  When you need to use an Excel Function, you can type the function into the cell. You also need to add the arguments for the function in between brackets. If the function is complex or you are a beginner user, there is a function inputting tool which will help you choose which function you require. 

5 0
3 years ago
Select all that apply. To select more than one worksheet at the same time, which of the following keys on your keyboard can you
Colt1911 [192]
<em>Shift </em>selects multiple worksheets at the same time. <em>Ctrl</em> selects all that you selected with Ctrl pressed.
4 0
3 years ago
13. Place where names, addresses and email information<br> is stored
yanalaym [24]

Answer in ur email

Explanation:

8 0
2 years ago
Other questions:
  • A typical self-expelling fire extinguisher empties its contents in
    8·1 answer
  • Why is it important to not get distracted while driving?
    13·2 answers
  • Which of the following actions might contribute to recommendations you see online?
    6·1 answer
  • You csn access various sites on the www by using hyperlinks or by
    7·1 answer
  • Eight what makes one character
    14·1 answer
  • Port explorers ​are tools used by both attackers and defenders to identify (or fingerprint) the computers that are active on a
    6·1 answer
  • A ____ is a statement specifying the condition(s) that must be true before the function is called.
    6·1 answer
  • What is the function of the NOS? Select all that apply.
    5·2 answers
  • You are writing a program to help compare two sports teams. A sample member of the list scores is [2. 5] where your team scored
    5·2 answers
  • What is a computer?write any four features of computer​
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!