Question: //Done in C please! //Any help appreciated! Write two programs to write and read from file the age and first and last names of people.

//Done in C please!

//Any help appreciated!

Write two programs to write and read from file the age and first and last names of people. The programs should work as follows:

1. The first program reads strings containing first and last names and saves them in a text file (this should be done with the fprintf function). The program should take the name of the file as a command line argument. The loop ends when the user enters 0, the program should function as follows (items in italics to be entered by user):

This program reads and saves ages and names in a binary file.

Enter person (age, first last):40, John Smith

Enter person (age, first last):32, Bill Jones

Enter person (age, first last):0

2. The second program reads in from the text file above (with the fscanf function) and prints out the ages and names on the screen. The program should take the name of the file as a command line argument. The program should function as follows (items in italics to be entered by user):

This program prints ages and names from a text file.

Name: 40, John Smith

Name: 32, Bill Jones

Algorithm design process

1. First program:

a. Declare needed variables.

b. Use command line arguments to open the file specified by the user for writing.

c. Enter the prompt and read the information from the user.

d. In a loop (until the user enters 0)

i. Use scanf to read age, first name, last name

ii. Use fprintf to write age, first name, last name to the file

e. Close the file.

2. Second program:

a. Declare needed variables (to store age, name string).

b. Use command line arguments to open the file specified by the user for reading.

c. In a loop until reaching the end of the file (EOF)

i. Use fscanf to read age, first name, last name

ii. If fscanf returns an integer not equal to 3, break the loop

iii. Print the information on the screen.

d. Close the file.

//Done in C please! //Any help appreciated! Write two programs to write

Write two programs to write and read from file the age and first and last names of people. The programs should work as follows: 1. The first program reads strings containing first and last names and saves them in a text file (this should be done with the fprintf function). The program should take the name of the file as a command line argument. The loop ends when the user enters 0 e This program reads and saves ages and names in a binary file Enter person (age, first last) :40, John Smith Enter person (age, First last) :32, Bill Jones Enter person (age, first last):0 nre, Eirat last):3 The second program reads in from the text file above (with the fscanf function) and prints out the ages and names on the screen. The program should take the name of the file as a command line argument. 2. This program prints ages and names from a text file Name 40, John Smith Name: 32, Bill Jones Algorithm design process 1. First program: a. Declare needed variables. b. Use command line arguments to open the file specified by the user for writing. c. Enter the prompt and read the information from the user d. In a loop (until the user enters 0) i. Use scanf to read age, first name, last name ii. Use fprintf to write age, first name, last name to the file Close the file. e. 2. Second program: Declare needed variables (to store age, name string). Use command line arguments to open the file specified by the user for reading. In a loop until reaching the end of the file (EOF) i. Use fscanf to read age, first name, last name ii. If fscanf returns an integer not equal to 3, break the loop ii. Print the information on the screen. a. b. c. d. Close the file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!