Hi gurus,
I have a problem here. I have forgotten how to pass a 2D array in a function . Normally an int** should do the deal, but no
Here is a sample code:
<br />
#include <stdio.h><br />
<br />
int g_tab[16][4]=<br />
{<br />
{ 0x03e0, 0x14a5, 0x0000, 0x0000, },<br />
{ 0x7fff, 0x6739, 0x4e73, 0x18c6, },<br />
{ 0x6460, 0x6431, 0x0821, 0x7bfe, },<br />
{ 0x0000, 0x001f, 0x03e0, 0x7c00, },<br />
{ 0x7fff, 0x7fff, 0x4631, 0x2529, },<br />
{ 0x7fff, 0x4a52, 0x2d6b, 0x0000, },<br />
{ 0x01e0, 0x0260, 0x0340, 0x0140, },<br />
{ 0x7bff, 0x1ce8, 0x5294, 0x7fff, },<br />
<br />
{ 0x67ff, 0x14a5, 0x56b5, 0x7fff, },<br />
{ 0x7fff, 0x6739, 0x4e73, 0x18c6, },<br />
{ 0x6460, 0x4631, 0x0821, 0x7bfe, },<br />
{ 0x0000, 0x0000, 0x0000, 0x0000, },<br />
{ 0x0000, 0x029d, 0x025b, 0x0195, },<br />
{ 0x0000, 0x0131, 0x00cf, 0x0047, },<br />
{ 0x0000, 0x01b6, 0x02df, 0x03e0, },<br />
{ 0x68ba, 0x6660, 0x7c00, 0x3460, },<br />
};<br />
<br />
void Apply(int** tab)<br />
{<br />
int y=0, x=0;<br />
<br />
for (y=0; y<16; y++)<br />
{<br />
for (x=0; x<4; x++)<br />
printf("%d ", tab[y][x]);<br />
<br />
printf("\n");<br />
}<br />
}<br />
<br />
int main()<br />
{<br />
Apply(g_tab);<br />
<br />
return 0;<br />
}<br />
I don't see what's wrong with the code, but it crashes when calling tab[y][x] .
Can anybody help me and tell me what's wrong please?
Best regards.
Fred.
There is no spoon.
|