Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ language 1. Create a struct that holds a char array of size 32 for a name, and an int for age. Ask the user

C++ language

1. Create a struct that holds a char array of size 32 for a name, and an int for age. Ask the user how many records they would like to create, then dynamically allocate that many structs. So if I enter that I want 5 records, youll create a dynamic array of size 5 of the struct data type. Once that is done, loop through the structs and ask the user for input on the name and the age for each record you created. Finally, display all the data to the screen.

Example Output How many records would you like? 2 What is the name for record 1? Bilbo Stabbins What is the age for record 1? 12 What is the name for record 2? Charlie Kelly What is the age for record 2? 35 Record 1 Name: Bilbo Stabbins Age: 12 Record 2 Name: Charlie Kelly Age: 35

2. Update the structure so that it no longer has a char pointer instead of a static array of size 32 for the name. Once you have allocated the array of structures, you must then go through and allocate the char array in each structure. The output and input should NOT change, were just adding an extra step here to make sure that the struct has dynamic memory in it. Example Output How many records would you like? 2 What is the name for record 1? Bobby Martinez What is the age for record 1? 99 What is the name for record 2? Robby Martinez What is the age for record 2? 31

Record 1 Name: Bobby Martinez Age: 99 Record 2 Name: Robby Martinez Age: 31

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

What Is A Database And How Do I Use It

Authors: Matt Anniss

1st Edition

1622750799, 978-1622750795

More Books

Students also viewed these Databases questions