Just write a default constructor for person, assuming it's a struct or class. It will be called to initialize each array element automatically.
In general, you should probably prefer to use std::vector<person> instead, but you haven't given enough context to say for sure.
The default constructor would look something like: this (note that std::string has its own default constructor, so we don't need to do anything for that)
struct person { std::string name; int value; person() : value(0) {} };
Now this:
person a[5];
is properly initialized with no further effort.
If you're planning to initialize the elements "properly" later anyway, then using a vector makes it easier to skip the wasted dummy initialization:
struct person { std::string name; int value; person() : value(0) {} person(std::string const &n, int v) : name(n), value(v) {} }; std::vector<person> people; people.reserve(5); // just create each person with the right values in the first place: for (int i = 0; i < 5; ++i) { people.push_back(person(get_name(i), get_value(i))); }
Finally, if you don't mind having uninitialized memory around, your first version (with no constructor and no loop) is fine. However, note that losing track of which elements/members are valid and which are garbage, is a fertile source of bugs.
person[5]is 6th position FYI