I have to setup a program that sets up a Date Structure (int month, day, year) and a Person structure (name and birthday - using the Date struct). Program needs a function (FillPerson) that asks the user to enter all the name and birthday information.
Here's where I run into trouble.
Need a function called WritePerson that writes out all the person information using the name of the month ( as opposed to the integer value) for the birthday month.
I need to have two Person variables and the program should fill these two variables and then call a function called WhoIsOlder, which is sent both person variables. The function determines who is older and writes the age status to the screen. WhoIsOlder should call WritePerson twice.
I made notes in my code about areas I need help with. Also any suggestions on constructing the WhoIsOlder function are welcome.
Thank You!
Code:#include <iostream.h> struct Date { int month,day,year; }; struct Person { char name[40]; Date birth; }; Person FillPerson(); void WritePerson(Person); int main () { char monthlist [12][80] = {"January", "February", "March", "Arpil", "May", "June", "July", "August", "September", "October", "November", "December"}; Person a,b; FillPerson(); WritePerson(WHAT GOES HERE?); //Need help here? return 0; } Person FillPerson() //is this the correct way to enter data for two different variables? { Person a,b; cout << "\n Enter the person's name: "; cin >> a.name; cout << "\n Enter the person's birthday in month, day, year, such as 1 21 1965: "<< endl; cin >> a.birth.month >> a.birth.day >> a.birth.year; cout << "\n Enter a second person's name: "; cin >> b.name; cout << "\n Enter the second person's birthday in month, day, year, such as 1 21 1965: "<< endl; cin >> b.birth.month >> b.birth.day >> b.birth.year; return a,b; } Person WritePerson(Person a, Person b) { cout << "\n Person one is " << a.name <<" and was born on " ; return a, b; } //how do I get the program to write out the month not the integer? // using a char array? how would I do that?



LinkBack URL
About LinkBacks


