Reputation: 1144
I was writing a code that involves handling a 2D array of dimensions [101]X[101] in C. However I am constrained in terms of memory being used at a given point of time.
void manipulate(int grid_recv[101][101])
{
//Something
}
void main()
{
int grid[101][101];
manipulate(grid);
}
So lets say I create an array grid[101][101] in my main() and then pass it for manipulation to another function. Now does the function manipulate() copy the entire matrix grid into grid_recv i.e by this sort of passing am I using twice the amount of memory ( i.e twice the size of grid)?
Upvotes: 5
Views: 222
Reputation: 4215
No. In C, arrays cannot be passed as parameters to functions.
What you actually do is creating a pointer pointing the array. So the extra memory you use it only the size of that pointer created.
Upvotes: 9