Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help. Using c-strings plz Parallel arrays and c-strings (char arrays). Note: all string operations should use c-strings, not string class or Cstring class. Read in

Help. Using c-strings plz image text in transcribed
image text in transcribed
Parallel arrays and c-strings (char arrays). Note: all string operations should use c-strings, not string class or Cstring class. Read in pairs of data from a text file. Each pair will include a name and an age. Store these two values in parallel arrays (an array of c-strings and an array of integers). (parallel means that the name and age should always be in the same position in their respective arrays) Sort both arrays according to names, alphabetically from first to last. Print out both arrays in the manner shown in the sample run. Sort both arrays according to age values from large to small. Print out both arrays again. Specifically Declare an array of 10 c-strings with each string being 30 characters long. (Note, that this really makes it a 2-Dimensional array lie. arrL10ll30l, but after declarations, the second subscript can be left off to handle an entire c-string. For example, arrl3] would be one c-string with 30 characters of storage. You never need to address individual characters, sojust one subscript except in declarations.) Declare an array of 10 integers. Call a getData function that will read data for up to 10 pairs of names and ages from an input file, and bring back the data. The file may be opened in the main program or inside this function. This function should bring back all of the data found in the input file ifthere are 10 or fewer pairs, or exactly 10 if the file contains extra data. The user should be asked to enter the name of the input file Call a function to sort both arrays according to name order from small to large (alphabetical first to last). The function should receive both arrays and the datasize. Compare only the names, but also swap the ages in the same place that you swap the names. Do not use the built-in swap0 function for swapping the c-string values. Call a print function that will write out names and ages in the format shown below. Call a function to sort both arrays according to age order from large to small. The function should receive both arrays and the datasize. Compare only the ages, but also swap the names in the same place that you swap the ages. Do not use the built-in swap0 function for swapping the c-string values. Call a print function that will write out names and ages in the format shown below. Note about passing an array of c-strings to functions: Because the array is really a 2-Dimensional array, the type declaration in the function heading (and prototype) needs to have 2 square brackets []0, but the second one must have the maximum size for that dimension, which in this case is the length of each string (30 characters]. So, a declaration in these locations will look like char x[IDMAXSIZEI, where MAXSIZE is either a numeric constant or a named constant. Once you get inside those functions, using just a single subscript will use the entire c-string (i.e. xlij) Comments

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago