Originally Posted by Peter_APIIT
Hello Sanskruti, you should start a new topic in c how to dynamic allocate memory because this features is quite useful and enhance flexibility of the program.
By the way, how to dynamic allocate memory for array of pointer and each pointer pointed to integer.
For example, int *array_ptr contain 10 pointer and each pointer pointing to integer.
The [n] form for array should automatically allocate the 10 pointers. Just like:
will automatically allocate 10 integers.
If you're referring to the integers themselves... you just allocate them before they're set.
array_ptr = &my_int; // & returns the address of the variable.
ptr_int = new int *; // if i remeber that properly
array_ptr = ptr_int;
That said.. all this stuff is ancient code heh. New causes so many problems.. especially when you allocate something and then forget to free the space.