each line in the input file will represent a record of data. There will be 10 lines, thus 10 records. Each record (line) will consist of 3 space separated fields: a name (1 word as a string), and age (as an integer), and a wage (as a float). Write a C program that: takes an input file name from the command line; opens that file if possible; declares a C struct with three variables; these will have data types that correspond to the data types read from the file (i.e. string, int, float); declares an array of C structs (i.e. the same struct type declared in point c); reads a record from the file and stores the values read into the appropriate struct variable at the appropriate array index (for that record); continues reading each record into a struct (as in point 1e), and stores each struct containing the 3 values into the array of structs declared in point d; closes the file when all records have been read.   should print an error message in the event that the file cannot be opened successfully.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 15RQ
icon
Related questions
Question

each line in the input file will represent a record of data. There will be 10 lines, thus 10 records. Each record (line) will consist of 3 space separated fields: a name (1 word as a string), and age (as an integer), and a wage (as a float).

Write a C program that:

    1. takes an input file name from the command line;
    2. opens that file if possible;
    3. declares a C struct with three variables; these will have data types that correspond to the data types read from the file (i.e. string, int, float);
    4. declares an array of C structs (i.e. the same struct type declared in point c);
    5. reads a record from the file and stores the values read into the appropriate struct variable at the appropriate array index (for that record);
    6. continues reading each record into a struct (as in point 1e), and stores each struct containing the 3 values into the array of structs declared in point d;
    7. closes the file when all records have been read.

 

should print an error message in the event that the file cannot be opened successfully.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr