C++ 3) Write a structure definition named Person that will allow the structure t
ID: 3838672 • Letter: C
Question
C++ 3) Write a structure definition named Person that will allow the structure to hold a last name of 30 characters, a first name of 20 characters, the person's date of birth (month, day, year), and the number of children the person has. The structure will also need to have the address of another structure of the same type in case this person has a spouse. (10 points)
6) Write a function named ToUpper which will have one parameter (a “C type” string). The function will convert the string into all upper case characters. (5 points)
Explanation / Answer
1.
struct dateOfBirth{
int day;
int month;
int year;
};
struct Person {
char firstname[20];
char lastname[30];
dateOfBirth dob;
int numOfChild;
struct Person *spouse;
};
2.
#include <iostream>
#include <locale> // std::locale, std::toupper
void ToUpper ( char *data)
{
std::locale loc;
char *p;
p = data;
while (*p){
cout << std::toupper(*p,loc);
p++;
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.