Pointer issue

Still fairly new to C++, the issue I'm getting here is "uninitialized local variable 'teams' used" in the line ">" is pointing to.

void initialize(vector <TeamS> & TeamV, const int ID[],
const string m[][NUM_MEMBERS], int arraySize)
TeamS* teams;
for (int i = 0; i < sizeof(ID); i++) {
> teams->ID = ID[i];
for (int j = 0; j < arraySize; j++) {
for (int k = 0; k < arraySize; k++) {
teams->teamMembers[i] = m[j][k];
You are attempting to dereference a pointer that has a random value.

On the fourth line you say:
TeamS* teams;
There is no initialization. teams has a random value — it can point anywhere in memory. Hence, line 6:
teams->ID = ID[i];
is an attempt to access random memory.

It would appear that this function desires to put values in the argument TeamV. You should do that:
  TeamS team;
  team.ID = ID[i];
  TeamV.push_back( team );

BTW, this is the Windows forum. You should have posted this in Beginners.

Hope this helps.
I see, thank you very much. Will do so in the future.
Topic archived. No new replies allowed.