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 in Figure 1 below. Make sure your output is exactly the same

person.txt
Mary 012-35678905 20000
John 010-87630221 16000
Alice 012-90028765 9000
Tom 019-76239028 30000
Pam 017-32237609 32000
app.cpp
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
struct person
{
char name[30];
char phone[15];
double money;
person *spouse;
};
int main()
{
person *p[10];
system("pause");
return 0;
}Hi i am answering your question hope this will be helpful to you , kindly give a thumbs up if it helps you and do comment if you have any doubt regarding the same.
Code:-
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string.h>
using namespace std;
typedef struct person //structure for the person i used typedef
so i do not need to use keyword struct every where
{
char name[30];
char phone[15];
double money;
person *spouse;
}person;
int main()
{
person *p[10] ;
ifstream in("person.txt"); //Opening file
int recCount = 0; // initilize the record conter to 0 and will give
the total no of entry in the file
while (!in.eof() )
{
p[recCount] = (person*)malloc(sizeof(person)); //providing size to
the pointer
in >> p[recCount]->name >>
p[recCount]->phone>>p[recCount]->money; // copying
values into the corrosponding fields
p[recCount]->spouse = NULL; // initilizing spouse to NULL as
said in the question
++recCount; // incresing rec count
}
for(int i = 0; i < recCount; i++)
{
if(strcmp(p[i]->name ,"Mary")==0)
{
for(int j = 0 ; j < recCount ; j++)
{
if(strcmp(p[j]->name , "Tom")==0)
{
p[i]->spouse = p[j]; // coping the address of the structer of
TOM to spouse of Mary
p[j]->spouse = p[i]; //coping the address of the structer of
Mary to spouse of Tom
}
}
}
cout<<"Name:"<<p[i]->name<<endl<<"Phone:"<<p[i]->phone<<endl<<"Money:"<<p[i]->money<<endl;
if(p[i]->spouse == NULL)
cout<<"Spouse Name:"<<"Not
Married"<<endl<<endl;
else
cout<<"Spouse
Name:"<<p[i]->spouse->name<<endl<<endl;
}
return 0;
}
output:-

Happy to help kindly give a thumbs up . and if still you have any doubt then you can comment.
Read person information in file person.txt and store to array p using DYNAMIC MEMORY. Set the...