Question: Write a program which, in general, reads a space delimited file named data2021.txt into an array of structures. Your program must then use a
Write a program which, in general, reads a space delimited file named data2021.txt into an array of structures. Your program must then use a function called print to print out the values inside of all structures where the occupation is "Musician" and the age is greater than 30. The file has 10 rows and 4 columns. Column 1 is the person's first and last name as a single string. Column 2 is an integer indicating the person's age. Column 3 is the person's occupation. Column 4 is a string containing the country the person was born. The structure must then contain 4 elements. The first element in the structure will be a string to hold the person's name. The second will be an integer to hold the person's age. The third will be a string to hold the person's occupation. The fourth will be a string to hold the country the person was born. Thus, each row is to be read into one of the structures in the array of structures. Specific instructions: In main(), read each row of the file into a structure contained in an array of structures. From main(), call the print function, passing the entire array to the function. The print function should therefore take the array of structures as an argument (parameter). In the function, run through each structure in the array and check to see if the occupation is "Musician" and the age is greater than 30. If it is, print out the name, age, occupation and country of birth of the person. If the person does not meet the conditions just outlined, do not print anything for that structure.
Step by Step Solution
There are 3 Steps involved in it
data2021txt LeonelRidley 32 Artist USA InocenciaCorkill 26 Doctor India LeDavalos 31 Musician Austra... View full answer
Get step-by-step solutions from verified subject matter experts
