You are not making your loop right. To go through array ALWAYS start at i = 0 and end at i = n-1. for(int i(0); i<n; i++) is ok (0 to n-1) for (int i(1);i<=n; i++) is not (1 to n)
Also, you cannot do this in standard C++: peoples_info person [n];
Standard complying compiler would reject that code, because size of array must be constant. The usual solution is to declare dynamic array with new keyword: http://www.cplusplus.com/doc/tutorial/dynamic/
Basically, you can probably just replace peoples_info person [n];
with vector<peoples_info> person(n); // initialize to n elements
and leave the rest of your code untouched (other than adding #include <vector> , of course), and it should work.