Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Array Question

Status
Not open for further replies.

PapaGLP

Technical User
Jul 19, 2002
31
0
0
US
i pass an array into a function like so

void intstuff(int **buffer){

}

i just need to know how to determine the actual size (in bytes) of the buffer, all i can get now is the size of the pointer . . . which is always 4
 
It is impossible to find out the size of a dynamically allocated array (using new or malloc). sizeof can only find out the size of static arrays like buffer[54]. If it was dynamically allocated there is no way to find out. Your best bet is to add an argument to the function (just an int) to keep track of the size. Well in your case since it is a 2-D array, you would want to pass in 2 ints and that will be your sizes for each dimension.

-Skatanic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top