Project about writing a program for storing information about a family member

I need help writing the following code:

A family has 4 members. You need to write a program to store the information of the family members and then to display it. The information to be stored for each member are:

First Name

Last Name

Date of Birth

Telephone number

Age

The age needs to be calculated based on current date and the Date of Birth. All these information except the age should be obtained from the user and should be stored in an array. Once the array has been populated (for all 4 members), print the complete information about each member of the family.
What have you written so far?
#include <iostream>
struct inflatable
{
char firstName[10];
char lastName[10];
int dateOfBirth[10];
int telephone[10];
int Age[3];

};
int main()
{
using namespace std;
inflatable members[1] = // initializing array of structs
{ firstName, lastname, dateOfBirth, telephone, Age}// naming the members for input
};

@LB
Last edited on
Please edit your post and make sure your code is [code]between code tags[/code] so that it has line numbers and syntax highlighting, as well as proper indentation.

You should use std::string instead of character arrays:
http://www.cplusplus.com/reference/string/string/
http://en.cppreference.com/w/cpp/string/basic_string
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
struct inflatable
{
	char firstName[10];
	char lastName[10];
	int dateOfBirth[10];
	int telephone[10];
	int Age[3]; 

};
int main()
{
	using namespace std::string;
	inflatable members[1] = // initializing array of structs 
	{ firstName, lastname, dateOfBirth, telephone, Age}// naming the members for input
};


like this?
No, I mean like this:
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <string>

struct Person
{
    std::string firstName, lastName;
    std::string dateOfBirth;
    std::string phone;
    int age;
};

//... 
Topic archived. No new replies allowed.