Re: Some doubts on variable-length array
- From: "lovecreatesbeauty" <lovecreatesbeauty@xxxxxxxxx>
- Date: 31 Mar 2006 02:00:45 -0800
I can understand the behaviour of these statements marked `/* A. don't
understand */' in following code, but do not understand the statements
marked `/* B. understand */' .
The behaviour of the following statements of A kind is different to B
kind.
Thank you.
#include <stdio.h>
void foo(int size_x, int size_y, int tab[size_x][size_y])
{
printf("tab[1][1] == %d\n", tab[1][1]);
}
int main()
{
/* int tab[9] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; */
int tab[3][3] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
foo(2, 2, tab); /* A. don't understand */
printf("%i\n", tab[2][2]); /* B. understand */
printf("%i\n", *(*(tab+2)+2)); /* B. understand */
printf("\n\n");
foo(3, 3, tab); /* A. don't understand */
printf("%i\n", tab[3][3]); /* B. understand */
printf("%i\n", *(*(tab+3)+3)); /* B. understand */
printf("\n\n");
return 0;
}
.
- Follow-Ups:
- Re: Some doubts on variable-length array
- From: Ben Bacarisse
- Re: Some doubts on variable-length array
- From: Fred Kleinschmidt
- Re: Some doubts on variable-length array
- References:
- Some doubts on variable-length array
- From: lovecreatesbeauty
- Some doubts on variable-length array
- Prev by Date: How to Identify functions in a .C File??
- Next by Date: Re: How to Define High-precision Date type
- Previous by thread: Some doubts on variable-length array
- Next by thread: Re: Some doubts on variable-length array
- Index(es):