T (*)[N] and T**

S

Siemel Naran

The following program causes a crash at runtime. But I expect it to print
"1,2,3,4,5,". Why?

#include <iostream>

int main()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;
int * * pp = static_cast<int * *>(v);
int * p = *pp;
for (int i=0; i<5; i++) std::cout << p << ',';
cout << '\n';
}

The type of 'array' can decay to a int*. Therefore I expect &array to be a
int**. Then when you cast from void*, you should cast to int**.


Yet this program works, which seems to imply that 'v' has type int*.

int main()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;
int * p = static_cast<int *>(v);
for (int i=0; i<5; i++) std::cout << p << ',';
cout << '\n';
}


Thanks.
 
J

Jonathan Turkanis

Siemel Naran said:
The following program causes a crash at runtime. But I expect it to print
"1,2,3,4,5,". Why?

#include <iostream>

int main()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;

The 'address of' operator is not a context in which an array decays to a
pointer. You're taking the real address here, which is the same as the address
of the first element.
int * * pp = static_cast<int * *>(v);
int * p = *pp;
for (int i=0; i<5; i++) std::cout << p << ',';
cout << '\n';
}

The type of 'array' can decay to a int*. Therefore I expect &array to be a
int**. Then when you cast from void*, you should cast to int**.


Yet this program works, which seems to imply that 'v' has type int*.


No, v has type void*.

You can witness the decay as follows:

#include <iostream>

void print_array(int* a)
{
void* v = &a;
int** pp = static_cast<int * *>(v);
int* p = *pp;
for (int i=0; i<5; i++) std::cout << p << ',';
std::cout << '\n';
}

int main()
{
int array[5] = { 1,2,3,4,5 };
print_array(array);
}

Jonathan
 
A

Alex Vinokur

Jonathan Turkanis said:
Siemel Naran said:
The following program causes a crash at runtime. But I expect it to print
"1,2,3,4,5,". Why?

#include <iostream>

int main()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;

The 'address of' operator is not a context in which an array decays to a
pointer. You're taking the real address here, which is the same as the address
of the first element.
int * * pp = static_cast<int * *>(v);
int * p = *pp;
for (int i=0; i<5; i++) std::cout << p << ',';
cout << '\n';
}

The type of 'array' can decay to a int*. Therefore I expect &array to be a
int**. Then when you cast from void*, you should cast to int**.


Yet this program works, which seems to imply that 'v' has type int*.


No, v has type void*.

You can witness the decay as follows:

#include <iostream>

void print_array(int* a)
{
void* v = &a;
int** pp = static_cast<int * *>(v);
int* p = *pp;
for (int i=0; i<5; i++) std::cout << p << ',';
std::cout << '\n';
}

int main()
{
int array[5] = { 1,2,3,4,5 };
print_array(array);
}

Jonathan


Here is a sample based on Siemel and Jonathan's postings.

###### foo.cpp : BEGIN ######
#include <iostream>
using namespace std;
typedef unsigned long ulong;

int main()
{
int array[5] = { 1, 2, 3, 4, 5 };
int* ptr = array;

cerr << hex << endl;

cerr << endl;
cerr << "ptr = " << ulong (ptr) << endl;
cerr << "&ptr = " << ulong (&ptr) << endl;
cerr << "array = " << ulong (array) << endl;
cerr << "&array = " << ulong (&array) << endl;


void * vp_array = array; // == &array[0]
void * vp_ptr = &ptr;


cerr << endl;
cerr << endl;
cerr << "==================" << endl;

cerr << endl;
cerr << "vp_ptr = " << ulong (vp_ptr) << endl;
cerr << "vp_array = " << ulong (vp_array) << endl;


int * * ipp_ptr = static_cast<int * *>(vp_ptr);
int * ip_ptr = *ipp_ptr;

cerr << endl;
cerr << "--- Via vp_ptr ---" << endl;
cerr << "vp_ptr = " << ulong (vp_ptr) << endl;
cerr << "ip_ptr = " << ulong (ip_ptr) << endl;
for (int i = 0; i < 5; i++) cerr << ip_ptr << " ";
cerr << endl;

cerr << endl;
cerr << endl;
cerr << "==================" << endl;

int * ip1_array = static_cast<int *>(vp_array);
int * * ipp_array = static_cast<int * *>(vp_array);
int * ip2_array = *ipp_array;

cerr << endl;
cerr << "ip1_array = " << ulong (ip1_array) << endl;
cerr << "ipp_array = " << ulong (ipp_array) << endl;
cerr << "ip2_array = " << ulong (ip2_array) << endl;


cerr << endl;
cerr << "--- Via vp_array & ip1_array ---" << endl;
cerr << "vp_array = " << ulong (vp_array) << endl;
cerr << "ip1_array = " << ulong (ip1_array) << endl;
for (int i = 0; i < 5; i++) cerr << ip1_array << " ";
cerr << endl;


cerr << endl;
cerr << "--- Via vp_array & ip2_array ---" << endl;
cerr << "vp_array = " << ulong (vp_array) << endl;
cerr << "ip2_array = " << ulong (ip2_array) << endl;
for (int i = 0; i < 5; i++) cerr << ip2_array << " ";
cerr << endl;


return 0;
}
###### foo.cpp : END ########



###### Compilation & Run : BEGIN ######


// g++ (GCC) 3.3.3 (cygwin special)

$ g++ -W -Wall foo.cpp


$ a

ptr = 22f040
&ptr = 22f03c
array = 22f040
&array = 22f040


==================

vp_ptr = 22f03c // pointer to array: array == &array == &array[0]
vp_array = 22f040 // array == &array == &array[0]

--- Via vp_ptr ---
vp_ptr = 22f03c // pointer to array: array == &array == &array[0]
ip_ptr = 22f040 // array == &array == &array[0]
1 2 3 4 5


==================

ip1_array = 22f040 // array == &array == &array[0]
ipp_array = 22f040 // !!! Also the same value because of void* --> "void * vp_array"
ip2_array = 1 // array[0]

--- Via vp_array & ip1_array ---
vp_array = 22f040 // array == &array == &array[0]
ip1_array = 22f040 // The same value
1 2 3 4 5

--- Via vp_array & ip2_array ---
vp_array = 22f040 // array == &array == &array[0]
ip2_array = 1 // array[0]
Segmentation fault (core dumped)


###### Compilation & Run : END ########
 
R

Rolf Magnus

Siemel said:
The following program causes a crash at runtime. But I expect it to print
"1,2,3,4,5,". Why?

I don't know why you expect that ;-)
#include <iostream>

int main()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;
int * * pp = static_cast<int * *>(v);

An array is not a pointer. What you do here is interpret the data that the
array contains as pointer. You take a pointer to the array, then convert it
into a pointer to pointer, treating the array as if it were a pointer.
int * p = *pp;
for (int i=0; i<5; i++) std::cout << p << ',';
cout << '\n';
}

The type of 'array' can decay to a int*. Therefore I expect &array to be
a int**.


No, it isn't. 'array' can decay into a pointer to int (i.e. it can be
implicitly converted into one), but it isn't one.
Then when you cast from void*, you should cast to int**.


Yet this program works, which seems to imply that 'v' has type int*.

In this program, you take the adress of the array, then interpret it as
pointer to int. Actually, it isn't ( it would be a pointer to array[5] of
int), but since the first element starts at the same address that the array
starts, your conversion succeeds and gives you a pointer to the array's
first element.
int main()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;
int * p = static_cast<int *>(v);
for (int i=0; i<5; i++) std::cout << p << ',';
cout << '\n';
}


Thanks.
 
O

Old Wolf

Siemel Naran said:
The following program causes a crash at runtime.
But I expect it to print "1,2,3,4,5,". Why?

#include <iostream>

int main()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;
int * * pp = static_cast<int * *>(v);
int * p = *pp;
for (int i=0; i<5; i++) std::cout << p << ',';
cout << '\n';
}

The type of 'array' can decay to a int*.
Therefore I expect &array to be a int**.


Where in memory do you think the four bytes (or whatever)
of *pp are?

(NB. This isn't a facetious comment - when you think about
it you will realise that they can only be the first four
bytes of 'array' )

Also, the array->pointer decay doesn't happen when the array
is subject to the unary '&' operator (nor does it happen
with ++, --, or sizeof).
 
S

Siemel Naran

Old Wolf said:
"Siemel Naran" <[email protected]>
int array[5] = { 1,2,3,4,5 };
void * v = &array;
int * * pp = static_cast<int * *>(v);
int * p = *pp;
for (int i=0; i<5; i++) std::cout << p << ',';
cout << '\n';
The type of 'array' can decay to a int*.
Therefore I expect &array to be a int**.


Where in memory do you think the four bytes (or whatever)
of *pp are?


Good point!
 
T

Tom Widmer

The following program causes a crash at runtime. But I expect it to print
"1,2,3,4,5,". Why?

#include <iostream>

int main()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;
int * * pp = static_cast<int * *>(v);
int * p = *pp;
for (int i=0; i<5; i++) std::cout << p << ',';
cout << '\n';
}

The type of 'array' can decay to a int*. Therefore I expect &array to be a
int**. Then when you cast from void*, you should cast to int**.


Yet this program works, which seems to imply that 'v' has type int*.

int main()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;
int * p = static_cast<int *>(v);
for (int i=0; i<5; i++) std::cout << p << ',';
cout << '\n';
}


This might help:
#include <iostream>

int main()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;
//int** ppp = &array;
int (*pp)[5] = static_cast<int(*)[5]>(v);
int * p = *pp; //usual array to pointer conversion
for (int i=0; i<5; i++) std::cout << p << ',';
std::cout << '\n';
}

Note that the ppp line won't compile. The address of an array is *not*
the same as a pointer to pointer to the elements of the array, and
this is because of the way that the elements are laid out in memory.

Tom
 
Z

zpwh

Siemel said:
The following program causes a crash at runtime. But I expect it to print
"1,2,3,4,5,". Why?

#include <iostream>

int main()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;
int * * pp = static_cast<int * *>(v);
int * p = *pp;
for (int i=0; i<5; i++) std::cout << p << ',';
cout << '\n';
}


I try this code:
int main ()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;
std::cout << "array = " << array
<< " &array = " << &array << "\n";
std::cout << "v = " << v << " "
<< "&v = " << &v << "\n";
int** pp = static_cast<int**>(v);
std::cout << "pp = " << pp
<< " &pp = " << &pp << "\n";
int* p = *pp;
std::cout << "p = " << p
<< " &p = " << &p << "\n";
//for (int i=0; i<5; i++)
// std::cout << p << ',';
std::cout << '\n';
}

result is:
array = 0012FE28 &array = 0012FE28
v = 0012FE28 &v = 0012FE1C
pp = 0012FE28 &pp = 0012FE10
p = 00000001 &p = 0012FE04

So, everything is clear. Jonathan Turkanis is right! Not a real int*
array, means "&array" is not different from "arrary"! It's just a
implicitly convert make you think arrary is a pointer to int. you just
get the address of arrary[0].
Static_cast is ok. but you may get a int** pp that address is
arrary[0].
*pp is the value "00000001". ha! p[0] means *"00000001",crash!
The type of 'array' can decay to a int*. Therefore I expect &array to be a
int**. Then when you cast from void*, you should cast to int**.


Yet this program works, which seems to imply that 'v' has type int*.

int main()
{
int array[5] = { 1,2,3,4,5 };
void * v = &array;
int * p = static_cast<int *>(v);
for (int i=0; i<5; i++) std::cout << p << ',';
cout << '\n';
}


Thanks.
 
A

Alex Vinokur

[snip]
Here is a sample based on Siemel and Jonathan's postings.

[snip]

Here is an updated sample based on Siemel, Jonathan and Tom's postings.


========= foo.cpp : BEGIN =========
#include <iostream>
#include <iomanip>
using namespace std;
typedef unsigned long ulong;

#define COUT cout << "[Line-" \
<< setw(3) \
<< std::right \
<< __LINE__ \
<< "] "

#define SHOW(x, y, z, t) \
COUT << "" \
<< y \
<< setw(19) \
<< std::left \
<< #x \
<< z \
<< setw(9) \
<< std::left \
<< ulong(x) \
<< dec \
<< std::right \
<< t \
<< endl

#define SHOW_HEX(x,t) SHOW(x, hex, " = 0x", t)
#define SHOW_DEC(x,t) SHOW(x, dec, " = ", t)

int main()
{
#define ARRAY_ELEMS 5

int array[ARRAY_ELEMS] = { 1, 2, 3, 4, 5 };
int * ptr = array;

void * vp_array = array; // == &array[0]
void * vp_ptr = &ptr;
int * * ipp_vp_ptr = static_cast<int * *>(vp_ptr);
int * ip_ipp_vp_ptr = *ipp_vp_ptr;

int * ip_vp_array = static_cast<int *>(vp_array);
int * * ipp_vp_array = static_cast<int * *>(vp_array);
int * ip_ipp_vp_array = *ipp_vp_array;

cout << endl;
SHOW_DEC (sizeof(*ipp_vp_array), "");

int (* ipa_vp_array)[ARRAY_ELEMS] = static_cast<int (*)[ARRAY_ELEMS]>(vp_array);
int * ip_ipa_vp_array = *ipa_vp_array;

SHOW_DEC (sizeof(*ipa_vp_array), "");


cout << endl;
SHOW_HEX (&array[0], "");
SHOW_HEX (&array[1], "");
SHOW_HEX (&array[2], "");
SHOW_HEX (&array[3], "");
SHOW_HEX (&array[4], "");

cout << endl;
SHOW_HEX (array, "&array[0]");
SHOW_HEX (&array, "&array[0]");
SHOW_DEC (*array, "array[0]");
cout << endl;
SHOW_HEX (ptr, "&array[0]");
SHOW_HEX (&ptr, "*ptr == &array[0]");
SHOW_DEC (*ptr, "array[0]");

cout << endl;
SHOW_HEX (vp_array, "&array[0]");
SHOW_HEX (vp_ptr, "*vp_ptr == &array[0]");
SHOW_HEX (ipp_vp_ptr, "*ipp_vp_ptr == &array[0]");
SHOW_HEX (ip_ipp_vp_ptr, "&array[0]");


cout << endl;
cout << endl;
cout << "------ ip_vp_array ------" << endl;
cout << endl;
SHOW_HEX (ip_vp_array, "&array[0]");
SHOW_HEX (ip_vp_array+1, "&array[1]");
SHOW_HEX (ip_vp_array+2, "&array[2]");
SHOW_HEX (ip_vp_array+3, "&array[3]");
SHOW_HEX (ip_vp_array+4, "&array[4]");

cout << endl;
SHOW_DEC (ip_vp_array[0], "array[0]");
SHOW_DEC (ip_vp_array[1], "array[1]");
SHOW_DEC (ip_vp_array[2], "array[2]");
SHOW_DEC (ip_vp_array[3], "array[3]");
SHOW_DEC (ip_vp_array[4], "array[4]");



cout << endl;
cout << endl;
cout << "------ ipp_vp_array ------" << endl;
cout << endl;
SHOW_HEX (ipp_vp_array, "&array[0]");
SHOW_HEX (ipp_vp_array+1, "&array[1]");
SHOW_HEX (ipp_vp_array+2, "&array[2]");
SHOW_HEX (ipp_vp_array+3, "&array[3]");
SHOW_HEX (ipp_vp_array+4, "&array[4]");

cout << endl;
SHOW_DEC (*ipp_vp_array, "array[0]");
SHOW_DEC (*(ipp_vp_array+1), "array[1]");
SHOW_DEC (*(ipp_vp_array+2), "array[2]");
SHOW_DEC (*(ipp_vp_array+3), "array[3]");
SHOW_DEC (*(ipp_vp_array+4), "array[4]");


cout << endl;
cout << endl;
cout << "------ ip_ipp_vp_array ------" << endl;
cout << endl;
SHOW_HEX (ip_ipp_vp_array, "array[0]");
SHOW_HEX (ip_ipp_vp_array+1, "array[0] + sizeof(*ipp_vp_array)" );
SHOW_HEX (ip_ipp_vp_array+2, "array[0] + 2*sizeof(*ipp_vp_array)");
SHOW_HEX (ip_ipp_vp_array+3, "array[0] + 3*sizeof(*ipp_vp_array)");
SHOW_HEX (ip_ipp_vp_array+4, "array[0] + 4*sizeof(*ipp_vp_array)");


cout << endl;
COUT << "\"cout << (*ip_ipp_vp_array)\" causes Segmentation fault" << endl;
// -------------------------
// Causes Segmentation fault
// SHOW_DEC (*ip_ipp_vp_array);
// SHOW_DEC (*(ip_ipp_vp_array+1));
// SHOW_DEC (*(ip_ipp_vp_array+2));
// SHOW_DEC (*(ip_ipp_vp_array+3));
// SHOW_DEC (*(ip_ipp_vp_array+4));
// -------------------------


cout << endl;
cout << endl;
cout << "------ ipa_vp_array ------" << endl;
cout << endl;
SHOW_HEX (&ipa_vp_array[0], "&array[0]");
SHOW_HEX (&ipa_vp_array[1], "&array[0] + sizeof(*ipa_vp_array)");
SHOW_HEX (&ipa_vp_array[2], "&array[0] + 2*sizeof(*ipa_vp_array)");

cout << endl;
SHOW_HEX (ipa_vp_array[0], "&array[0]");
SHOW_HEX (ipa_vp_array[1], "&array[0] + sizeof(*ipa_vp_array)");
SHOW_HEX (ipa_vp_array[2], "&array[0] + 2*sizeof(*ipa_vp_array)");

cout << endl;
SHOW_HEX (ipa_vp_array, "&array[0]");
SHOW_HEX (ipa_vp_array+1, "&array[0] + sizeof(*ipa_vp_array)");
SHOW_HEX (ipa_vp_array+2, "&array[0] + 2*sizeof(*ipa_vp_array)");


cout << endl;
SHOW_HEX (&ipa_vp_array[0][0], "&array[0]");
SHOW_HEX (&ipa_vp_array[0][1], "&array[1]");
SHOW_HEX (&ipa_vp_array[0][2], "&array[2]");
SHOW_HEX (&ipa_vp_array[0][3], "&array[3]");
SHOW_HEX (&ipa_vp_array[0][4], "&array[4]");
SHOW_HEX (&ipa_vp_array[1][0], "");
SHOW_HEX (&ipa_vp_array[1][1], "");
SHOW_HEX (&ipa_vp_array[1][2], "");

cout << endl;
SHOW_DEC (ipa_vp_array[0][0], "array[0]");
SHOW_DEC (ipa_vp_array[0][1], "array[1]");
SHOW_DEC (ipa_vp_array[0][2], "array[2]");
SHOW_DEC (ipa_vp_array[0][3], "array[3]");
SHOW_DEC (ipa_vp_array[0][4], "array[4]");


cout << endl;
cout << endl;
cout << "------ ip_ipa_vp_array ------" << endl;
cout << endl;
SHOW_HEX (ip_ipa_vp_array, "&array[0]");
SHOW_HEX (ip_ipa_vp_array+1, "&array[1]");
SHOW_HEX (ip_ipa_vp_array+2, "&array[2]");
SHOW_HEX (ip_ipa_vp_array+3, "&array[3]");
SHOW_HEX (ip_ipa_vp_array+4, "&array[4]");

cout << endl;
SHOW_DEC (ip_ipa_vp_array[0], "array[0]");
SHOW_DEC (ip_ipa_vp_array[1], "array[1]");
SHOW_DEC (ip_ipa_vp_array[2], "array[2]");
SHOW_DEC (ip_ipa_vp_array[3], "array[3]");
SHOW_DEC (ip_ipa_vp_array[4], "array[4]");

return 0;
}
========= foo.cpp : END ===========




========= Compilation & Run : BEGIN =========

// g++ (GCC) 3.3.3 (cygwin special)

$ g++ -W -Wall foo.cpp

$ a

[Line- 47] sizeof(*ipp_vp_array) = 4
[Line- 52] sizeof(*ipa_vp_array) = 20

[Line- 56] &array[0] = 0x22f040
[Line- 57] &array[1] = 0x22f044
[Line- 58] &array[2] = 0x22f048
[Line- 59] &array[3] = 0x22f04c
[Line- 60] &array[4] = 0x22f050

[Line- 63] array = 0x22f040 &array[0]
[Line- 64] &array = 0x22f040 &array[0]
[Line- 65] *array = 1 array[0]

[Line- 67] ptr = 0x22f040 &array[0]
[Line- 68] &ptr = 0x22f03c *ptr == &array[0]
[Line- 69] *ptr = 1 array[0]

[Line- 72] vp_array = 0x22f040 &array[0]
[Line- 73] vp_ptr = 0x22f03c *vp_ptr == &array[0]
[Line- 74] ipp_vp_ptr = 0x22f03c *ipp_vp_ptr == &array[0]
[Line- 75] ip_ipp_vp_ptr = 0x22f040 &array[0]


------ ip_vp_array ------

[Line- 82] ip_vp_array = 0x22f040 &array[0]
[Line- 83] ip_vp_array+1 = 0x22f044 &array[1]
[Line- 84] ip_vp_array+2 = 0x22f048 &array[2]
[Line- 85] ip_vp_array+3 = 0x22f04c &array[3]
[Line- 86] ip_vp_array+4 = 0x22f050 &array[4]

[Line- 89] ip_vp_array[0] = 1 array[0]
[Line- 90] ip_vp_array[1] = 2 array[1]
[Line- 91] ip_vp_array[2] = 3 array[2]
[Line- 92] ip_vp_array[3] = 4 array[3]
[Line- 93] ip_vp_array[4] = 5 array[4]


------ ipp_vp_array ------

[Line-101] ipp_vp_array = 0x22f040 &array[0]
[Line-102] ipp_vp_array+1 = 0x22f044 &array[1]
[Line-103] ipp_vp_array+2 = 0x22f048 &array[2]
[Line-104] ipp_vp_array+3 = 0x22f04c &array[3]
[Line-105] ipp_vp_array+4 = 0x22f050 &array[4]

[Line-108] *ipp_vp_array = 1 array[0]
[Line-109] *(ipp_vp_array+1) = 2 array[1]
[Line-110] *(ipp_vp_array+2) = 3 array[2]
[Line-111] *(ipp_vp_array+3) = 4 array[3]
[Line-112] *(ipp_vp_array+4) = 5 array[4]


------ ip_ipp_vp_array ------

[Line-119] ip_ipp_vp_array = 0x1 array[0]
[Line-120] ip_ipp_vp_array+1 = 0x5 array[0] + sizeof(*ipp_vp_array)
[Line-121] ip_ipp_vp_array+2 = 0x9 array[0] + 2*sizeof(*ipp_vp_array)
[Line-122] ip_ipp_vp_array+3 = 0xd array[0] + 3*sizeof(*ipp_vp_array)
[Line-123] ip_ipp_vp_array+4 = 0x11 array[0] + 4*sizeof(*ipp_vp_array)

[Line-127] "cout << (*ip_ipp_vp_array)" causes Segmentation fault


------ ipa_vp_array ------

[Line-142] &ipa_vp_array[0] = 0x22f040 &array[0]
[Line-143] &ipa_vp_array[1] = 0x22f054 &array[0] + sizeof(*ipa_vp_array)
[Line-144] &ipa_vp_array[2] = 0x22f068 &array[0] + 2*sizeof(*ipa_vp_array)

[Line-147] ipa_vp_array[0] = 0x22f040 &array[0]
[Line-148] ipa_vp_array[1] = 0x22f054 &array[0] + sizeof(*ipa_vp_array)
[Line-149] ipa_vp_array[2] = 0x22f068 &array[0] + 2*sizeof(*ipa_vp_array)

[Line-152] ipa_vp_array = 0x22f040 &array[0]
[Line-153] ipa_vp_array+1 = 0x22f054 &array[0] + sizeof(*ipa_vp_array)
[Line-154] ipa_vp_array+2 = 0x22f068 &array[0] + 2*sizeof(*ipa_vp_array)

[Line-158] &ipa_vp_array[0][0] = 0x22f040 &array[0]
[Line-159] &ipa_vp_array[0][1] = 0x22f044 &array[1]
[Line-160] &ipa_vp_array[0][2] = 0x22f048 &array[2]
[Line-161] &ipa_vp_array[0][3] = 0x22f04c &array[3]
[Line-162] &ipa_vp_array[0][4] = 0x22f050 &array[4]
[Line-163] &ipa_vp_array[1][0] = 0x22f054
[Line-164] &ipa_vp_array[1][1] = 0x22f058
[Line-165] &ipa_vp_array[1][2] = 0x22f05c

[Line-168] ipa_vp_array[0][0] = 1 array[0]
[Line-169] ipa_vp_array[0][1] = 2 array[1]
[Line-170] ipa_vp_array[0][2] = 3 array[2]
[Line-171] ipa_vp_array[0][3] = 4 array[3]
[Line-172] ipa_vp_array[0][4] = 5 array[4]


------ ip_ipa_vp_array ------

[Line-179] ip_ipa_vp_array = 0x22f040 &array[0]
[Line-180] ip_ipa_vp_array+1 = 0x22f044 &array[1]
[Line-181] ip_ipa_vp_array+2 = 0x22f048 &array[2]
[Line-182] ip_ipa_vp_array+3 = 0x22f04c &array[3]
[Line-183] ip_ipa_vp_array+4 = 0x22f050 &array[4]

[Line-186] ip_ipa_vp_array[0] = 1 array[0]
[Line-187] ip_ipa_vp_array[1] = 2 array[1]
[Line-188] ip_ipa_vp_array[2] = 3 array[2]
[Line-189] ip_ipa_vp_array[3] = 4 array[3]
[Line-190] ip_ipa_vp_array[4] = 5 array[4]

========= Compilation & Run : END ===========
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,978
Members
47,561
Latest member
gjsign

Latest Threads

Top