Top "Dynamic-allocation" questions

Dynamic memory allocation, usually in the context of languages without garbage collection or mandatory or automatic reference counting, refers to the process or asking the operating system for a variable sized block of memory.

How do I declare a 2d array in C++ using new?

How do i declare a 2d array using new? Like, for a "normal" array I would: int* ary = new int[…

c++ arrays multidimensional-array dynamic-allocation
Is it good practice to NULL a pointer after deleting it?

I'll start out by saying, use smart pointers and you'll never have to worry about this. What are the problems …

c++ pointers null dynamic-allocation
memory allocation in Stack and Heap

This may seem like a very basic question, but its been in my head so: When we allocate a local …

c memory-management heap-memory dynamic-allocation stack-memory
warning: function returns address of local variable [enabled by default]

#include <string.h> #include<stdio.h> #include<stdlib.h> char *chktype(char *Buffer, int …

c dynamic-allocation
Dynamically allocated 2 dimensional array

I am trying to build two dimensional array by dynamically allocating. My question is that is it possible that its …

c multidimensional-array dynamic-arrays dynamic-allocation
Finding size of dynamically allocated array

Why is it not possible to get the length of a buffer allocated in this fashion. AType * pArr = new AType[…

c++ size new-operator dynamic-allocation
Does std::array<> guarantee allocation on the stack only?

Is std::array<int,10> (without myself using new) guaranteed to be allocated in the stack rather then the …

c++ arrays stack dynamic-allocation static-allocation
Can I free() static and automatic variables in C?

The code is as follow : #include <stdlib.h> int num = 3; // Static external variable int *ptr = &num; int …

c free scope static-variables dynamic-allocation
Should I free memory before exit?

Should I free all my mallocated memory when I am exiting program in the due of error? something = (char**) malloc (…

c malloc free dynamic-allocation
Correctly allocating multi-dimensional arrays

The intent of this question is to provide a reference about how to correctly allocate multi-dimensional arrays dynamically in C. …

c arrays dynamic-arrays dynamic-allocation variable-length-array