function LoadUsers() must allocate space for each of the character arrays in the users array. All it is currently doing is using the same std::string over and over again, each time destroying the value of the previous time.
Two fixes:
1. re-declare char* users[100] as vector users.
or
2. replace line 43 >>users[counter] = line.c_str()
with this
users[counter] = strdup(line.c_str());
strdup() does two things:
users[counter] = malloc(length+1);
strcpy(users[counter], line.c_str());
If you opt for option 2 then you need to free() each of those strings when finished with them.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343