Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A structure person is defined in a program CA2-template.cpp. An array of pointer to person, p is created for you to store up to 10

A structure person is defined in a program CA2-template.cpp. An array of pointer to person, p is created for you to store up to 10 persons using dynamic memory.

CA2-template.cpp

#include #include #include

using namespace std;

struct person { char name[30]; char phone[15]; double money; person *spouse; };

int main() { person *p[10];

system("pause"); return 0; }

  1. Read person information in file person.txt and store to array p. Set the spouse pointer for each person to NULL value first.
  2. Perform marry operation for Mary and Tom. You can marry two person by setting their spouse pointer to point to each other (store address of one another).
  3. Print out the content in array p where you need to print every person variable pointed by array p. If a person spouse pointer is NULL value, then print Not Married, else print the spouse name. Output of the program is shown below. Make sure your output is the same

person.txt

Mary 012-35678905 20000 John 010-87630221 16000 Alice 012-90028765 9000 Tom 019-76239028 30000 Pam 017-32237609 32000

Output

image text in transcribed

Dluccd1024\may2018\Assignment1\test-roject-jan20191Debug\test-roject-jan2019.exe lame: Mar Phone: 012-35678905 Money: 20000 Spouse Name: Tom lame: John Phone: 010-87630221 Money: 16000 Spouse Name: Not Married ame: Alice Phone: 012-90028765 oney: 9000 Spouse Name: Not Married lame: Tom Phone: 019-76239028 oney: 30000 Spouse Name: Mary Name: Pam Phone: 017-32237609 oney: 32000 Spouse Name: Not Married Press any key to continue

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_2

Step: 3

blur-text-image_3

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

Genomes Browsers And Databases Data Mining Tools For Integrated Genomic Databases

Authors: Peter Schattner

1st Edition

0521711320, 978-0521711326

More Books

Students also viewed these Databases questions

Question

7. Define cultural space.

Answered: 1 week ago

Question

8. Describe how cultural spaces are formed.

Answered: 1 week ago