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
Does analogue conversation take place in source as transmitter?
Sati [7]

Answer:Analog and digital signals are the types of signals carrying information. The major difference between both signals is that the analog signals that have continuous electrical signals, while digital signals have non-continuous electrical signals.

Explanation:

5 0
3 years ago
Read 2 more answers
Maria found a cupcake recipe on a cooking blog. However, she would like to read comments and suggestions before she begins bakin
Mnenie [13.5K]
Maria should use the Cooking blog that has known and verified information and step by step instructions Comments can lead to disaster and/or incorrect recipe use
8 0
3 years ago
Read 2 more answers
Who would win in a fight iron man or bat man​
MatroZZZ [7]
IRON MANNNN MARVELLLL
8 0
3 years ago
Read 2 more answers
Which problem is least likely to be solved through grid computing?.
maxonik [38]

Answer:

Which of the following problems is least likely to be solved through grid computing? Linear problems. Price elasticity refers to: rate at which demand for a product or service fluctuates with price change.

Explanation:

7 0
2 years ago
Given a string variable named sentence that has been initialized , write an expression whose value is the the very last characte
Blizzard [7]
Strings can usually be dealt with as arrays of characters.

sentence[ -1 ]

sentence.substring( sentence.size() -1 );
8 0
3 years ago
Other questions:
  • My computer have black spots and line
    7·2 answers
  • The Sumif formula will add numbers together from a range of numbers ONLY IF they contain the criteria. True or false
    8·1 answer
  • Write a Python program to do the following:
    12·1 answer
  • Reasons for the growth of decision-making systems include:
    13·1 answer
  • to add data to to a chart, you must format data from another microsoft office product, that automatically opens. whats the name
    10·1 answer
  • Define artificial intelligence?​
    15·2 answers
  • Write a boolean expression that is true if s references the string end.
    8·1 answer
  • ________ is a group meeting-based process for requirements collection. a. Reverse engineering b. Joint application design c. Hum
    9·1 answer
  • Modern life is not possible if computer stops working? Give your opinion<br>​
    7·1 answer
  • I have the requirements for Ace rank on Brainly but hasn't given me it yet. Does it just take longer than normal ranks or someth
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!