Why did you define names as a 2D array with 10 columns? Do you think you need to do this because you are going to create 10 person objects?
If this happens, keep this in mind: when creating a person structure, you just need to define member variables for this single object .
So, if your person has only one name and one gender (which requires 6 characters), just use this because when you create 10 objects of a person ( person student[10]; ), you create 10 unique copies of the person object ! So person[0].name is different from person[1].name .
So, first define the member variables in person for one person:
struct person { char names[20]; char sex[6]; int age; int month; int day; int year; };
And then assign the characters to the name as you indicated in your code.
Now this is not a great idea, because names not initialized. Thus, student[0].names[4] is undefined (when it must have a null character to complete it). Do you consider using std::string ? You have C ++ in the end!
Also, you will notice that I have changed the definition of person ('struct person ... instead of typedef .. `), as that is all you need to do in C ++.
Changes:
Consider the following person structure:
#include <string> struct person { std::string person; std::string sex; int age; int month; int day; int year; };
Now you can assign a line simply:
person student[10]; student[0].name = "Cami"; student[0].sex = "Female"; student[0].age = 16; student[0].month = 8; student[0].day = 2; student[0].year = 1993;
And suppose you want to fill it with a for loop using keyboard input --- now it's a lot easier:
#include <iostream> for(int i = 0; i < 10; ++i) { std::cin>>student[i].name; std::cin>>student[i].sex; std::cin>>student[i].age; std::cin>>student[i].month; std::cin>>student[i].day; std::cin>>student[i].year; }