Trying to change int* value declared in main() via another function.

Hello! I have the following question.
I have this code:
1
2
3
4
5
int main()
{
  unsigned int *dWords = NULL;
  return 0;
}


I want to change the value of dWords via another function by passing it to the function as a parameter, so i can use its(dWords) new value so I can passed this new value to another function in main something like this.
1
2
3
4
5
6
7
int main()
{
  unsigned int *dWords = NULL;
  changedWords(dWords); // from here i need the dWords value to be changed 
  usedWordsNewValueForSomethingElse(dWords);//so I can use it here
  return 0;
}


Thank you!
well, if, for example, you wanted to change an int you would have to pass it by pointer or reference. so if you want to change int* pass it by pointer (int**) of by reference (int*&).
example:
1
2
void changeptr(int** i){*i = new int;}
void changeref(int*& i){i = new int;}
Topic archived. No new replies allowed.