Yay another pointer question!

I am trying to understand pointers, but I have issue with setting up the pointer especially to arrays. Like for example,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  int main() 
{ 
	int size;
	int MM [2] = {1000, 0}; 
	int *theG = NULL; 
	int *PMM = NULL; 
	cout << "\nPlease insert size of array:" << endl; 
	cin >> size; 
	theG = new int [size]; 
	PMM [] = &MM; //  Here I get an error.  
	findMM(&MM, &theG); //findMM is a function I haven't written yet. 
	delete [] PMM; 
	delete [] theG; 	
	return 0; 
}


Ultimately I am trying to figure out what I am doing wrong. :(
PMM [] = &MM; // Here I get an error.
That line doesn't really make any sense. The brackets don't make any sense at all, and any array can be assignable to a pointer, so you don't need the '&' operator.

PMM = MM; should work just fine.

The tutorial does a good job explaining it: http://www.cplusplus.com/doc/tutorial/pointers/
ahh I see thanks.
closed account (NyqLy60M)
The macro NULL is defined as 0 (in stdio.h), so all you're really doing is typing more than what's necessary on lines 5 and 6.
Topic archived. No new replies allowed.