Top "Allocation" questions

Memory allocation is an operation of giving a program a block of memory.

Allocate memory 2d array in function C

How to allocate dynamic memory for 2d array in function ? I tried this way: int main() { int m=4,n=3; int** …

c arrays function 2d allocation
dynamic allocating array of arrays in C

I don't truly understand some basic things in C like dynamically allocating array of arrays. I know you can do: …

c arrays memory dynamic-memory-allocation allocation
Are Structs always stack allocated or sometimes heap allocated?

I was of the impression that in C#, struct elements are allocated on the stack and thus disappear when returning …

c# struct allocation
What is the difference between [Class new] and [[Class alloc] init] in iOS?

Possible Duplicate: alloc, init, and new in Objective-C I am a little confused about [Class new] and [[Class alloc] init]. …

ios objective-c new-operator allocation init
In what cases should I use memcpy over standard operators in C++?

When can I get better performance using memcpy or how do I benefit from using it? For example: float a[3]; …

c++ performance memory allocation copying
Dynamically allocate C struct?

I want to dynamically allocate a C struct: typedef struct { short *offset; char *values; } swc; Both 'offset' and 'values' are …

c++ c memory allocation
C++ Multi-dimensional Arrays on the Heap

How would I go about dynamically allocating a multi-dimensional array?

c++ arrays memory heap allocation
Should I check if malloc() was successful?

Should one check after each malloc() if it was successful? Is it at all possible that a malloc() fails? What …

c error-handling malloc runtime-error allocation
Passing around fixed-size arrays in C++?

Basically I'd like to do something like that: int[3] array_func() { return {1,1,1}; } int main(int argc,char * argv[]) { int[3] point=…

c++ performance allocation numerical
How to add string to array of strings in C

So I am getting re-acquainted with C, and this one concept has me particularly stuck. The goal is to create …

c arrays string memory allocation