1
C - C++ / Re: pointers and 2d array
« on: February 08, 2016, 05:39:41 pm »
When you assign a pointer to an array it Only points to the address of the first element.
Since the first element is an int variable the pointer Will be an integer whose size is 4 bytes
And simply assign the pointer variable to the array as I said it will point only to the first element of the array.
And if passing pointers to the function is ur sole moto then u don't even need to use a pointer variable. C++ does that for u.
For example
If the prototype of the function is
Void fun(int a[ 100][ 100])
Then simply call the function using the array ar by
Fun(ar);
The when u pass the array ar only its pointer is passed ar can also be a dynamic array .
Hope this helps
Since the first element is an int variable the pointer Will be an integer whose size is 4 bytes
And simply assign the pointer variable to the array as I said it will point only to the first element of the array.
And if passing pointers to the function is ur sole moto then u don't even need to use a pointer variable. C++ does that for u.
For example
If the prototype of the function is
Void fun(int a[ 100][ 100])
Then simply call the function using the array ar by
Fun(ar);
The when u pass the array ar only its pointer is passed ar can also be a dynamic array .
Hope this helps