S
Sac
Hello C Gurus,
I have following questions regarding passing two dimensional
array to a function:
1. In memory single and two dimensional arrays are stored in
same fashion by allocating a set of consecutive memory locations. Is
there any specific reason for allocating a different type pointer for
two dimensional arrays.
For example:
int a[3][4];
int *p;
p=a;
should works because a internally 'a' points to a set of
consecutive memory locations.
2. As per K&R when 2 dimensional array is passed to a function
number or rows is irrelevant and number of columns is a must. However
when array get passed on to a function its passed as a pointer then
why its required to pass even columns?
Please let me know if questions are not clear.
Thanking in advance
Sac
I have following questions regarding passing two dimensional
array to a function:
1. In memory single and two dimensional arrays are stored in
same fashion by allocating a set of consecutive memory locations. Is
there any specific reason for allocating a different type pointer for
two dimensional arrays.
For example:
int a[3][4];
int *p;
p=a;
should works because a internally 'a' points to a set of
consecutive memory locations.
2. As per K&R when 2 dimensional array is passed to a function
number or rows is irrelevant and number of columns is a must. However
when array get passed on to a function its passed as a pointer then
why its required to pass even columns?
Please let me know if questions are not clear.
Thanking in advance
Sac