Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

A little help with pointers

Name: Anonymous 2011-02-04 15:02


main ()
{
     int A[1][2][3][4];
     //I put random values in it
     G(&A[0][0][0][0]);
}

void G(int *A)
{
     cout << A[2][2][3][4];
}


It says me "Invalid type 'int[int]' for array subscript"... Why?

Name: Anonymous 2011-02-04 15:04

Sorry... It's

void G(int *A)
{
     cout << A[1][2][3][4];
}

Name: Anonymous 2011-02-04 15:08

try void G(int ****A)

Name: Anonymous 2011-02-04 15:15

Nope. The problem is that if i use, it works...

cout<<*(A+1*2*3*4*sizeof(int)+2*3*4*sizeof(int)+3*4*sizeof(int)+4*sizeof(int))


I read in a book that this code should work, but it doen's work for me.

void G(int *A)
{
     int n=A[1][2][3][4];
     cout << n;
}

Name: Anonymous 2011-02-04 15:18

It says me "Invalid type 'int[int]' for array subscript"... Why?

Because the 'int[int]' type is invalid as an array subscript.

Name: Anonymous 2011-02-04 15:18

>>4
A is an int****, see >>3.

Name: Anonymous 2011-02-04 15:28

>>6

See what >>1 is calling it with though.

Name: Anonymous 2011-02-04 15:31

>>7
&A is an int*****.

Name: Anonymous 2011-02-04 16:06

void G(int ************************************A)

EXPERT ''FAGOT''

Name: Anonymous 2011-02-04 16:07

It's not an array of arrays of arrays of arrays. Behind the scenes its just a regular 1D array. When you index into the ``subarrays'' the compiler needs to know the dimensions you've specified so that it can figured out the location in the 1D array.

void G(int A[1][2][3][4])
{
}

main ()
{
    int A[1][2][3][4];
 
  G(A);
}

Name: Anonymous 2011-02-04 17:11

U MENA
void G(int *A)
{
     cout << (*A)[1][2][3][4];
}

Name: Anonymous 2011-02-04 17:26

>>11
A[0][1][2][3][4];

Name: Anonymous 2011-02-04 17:31

Thanks everybody

Name: Anonymous 2011-02-04 17:32

>>13
No problem. Just be sure to sage your posts in the future!

Name: VIPPER 2011-02-04 17:38

>>14
Sage my anus.

Name: Anonymous 2011-02-04 17:42

>>14
mai--
WHAT

Name: Anonymous 2011-02-04 18:47

>>16
mai waifu

Name: Anonymous 2011-02-04 20:04

>>17
;_;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List