Iterate a Dynamically Allocated Array

I need to dynamically allocate an array of type int with size 12MB. I did it as follows:

unsigned int *memory;
memory = (int *) malloc( 3072 * sizeof(int));

How would I iterate through the array without having to use 3072? Is there a way to get the length of the array? Or should I just do for (int i = 0; i < 3072; i++)?



The is no portable or convenient way to find out how large the allocate chunk is. After malloc is done all that is visible is a pointer to an indeterminate amount of memory (*). You must do the bookkeeping yourself.

(*) Actually malloc and friends do know how large the chunk is but there is no standard way for a client to access this information.

Need Your Help

How to use cq:includeClientLib in CQ5 to include CSS and Javascript

javascript css cq5

What are the js and css include concepts in CQ5 using clientLibrary[cq:includeClientLib]? It would be great to have an example with screen shot.

Populating options for drop down list

sharepoint-2010 infopath sharepoint-designer

I have a list that I will have users enter data into, each user needs to select their own location. First I created a drop down field with all the options. The column can be set to force unique v...