How to init an array dynamically on the heap?
Hi!
How to init an array dynamically on the heap in C ( in C++ its easy). To init an array on the stack, I write:
int size = 1000;
int stackarray[size];
How to do the same on the heap?
int* heaparray = (int*) malloc (size);
But: my heaparray pointer doesnot know its a pointer to an array. And I want him to know that, because my Borland VCC6 Debugger should show me the array fields. Is there a way to do that with simple typecasting like
(int[size]) heaparray
which doesnot work.
???
Re: How to init an array dynamically on the heap?
Quote:
Originally posted by karantsch
Hi!
How to init an array dynamically on the heap in C ( in C++ its easy). To init an array on the stack, I write:
int size = 1000;
int stackarray[size];
How to do the same on the heap?
int* heaparray = (int*) malloc (size);
But: my heaparray pointer doesnot know its a pointer to an array. And I want him to know that, because my Borland VCC6 Debugger should show me the array fields. Is there a way to do that with simple typecasting like
(int[size]) heaparray
which doesnot work.
???
No.