What does this actually mean?

Z

ziwu

int* ptrArray[ARRAY_SIZE];

Does it mean: define an array of pointers pointing to data type of int?

Does it differ from "int **matrix;" by the fact that both dimentions of
"matrix" is unknown but one dimention of "ptrArray" is known at compile
time?

Thanks for your help!
 
L

Lew Pitcher

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
int* ptrArray[ARRAY_SIZE];

Does it mean: define an array of pointers pointing to data type of int?

It means that ptrArray is defined as an ARRAY_SIZE array of pointers to integers.
Does it differ from "int **matrix;"

Yes.

In this case, matrix is defined as a pointer to a pointer to an integer. That
is definitely not the same thing as an ARRAY_SIZE array of pointers to integers.

by the fact that both dimentions of
"matrix" is unknown but one dimention of "ptrArray" is known at compile
time?

Partially. But more completely, matrix is different from ptrArray because it
is a pointer, while ptrArray is an array.

- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBFZxNagVFX4UWr64RAjXyAJ4j5m0hiJRCB/XwXbc/XDuccSyQngCg9NiW
57OFroqjqt06ipOS8UPic1o=
=vQOj
-----END PGP SIGNATURE-----
 
W

William L. Bahn

ziwu said:
int* ptrArray[ARRAY_SIZE];

Does it mean: define an array of pointers pointing to data type of int?

Yes. And most importantly (wrt to your next question) memory is allocated to
hold the specified number of pointers. The identifier ptrArray is a pointer
to the beginning of this space.
Does it differ from "int **matrix;" by the fact that both dimentions of
"matrix" is unknown but one dimention of "ptrArray" is known at compile
time?

int **matrix;

This only allocates enough memory to store a single pointer. It is
unitialized and no memory has been been alocated to store any int pointers.
 

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

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top