Top "Malloc" questions

The malloc function performs dynamic memory allocation in C and is part of the standard library.

How can I declare and initialize an array of pointers to a structure in C?

I have a small assignment in C. I am trying to create an array of pointers to a structure. My …

c null pointers malloc structure
Need more information about Aborted (core dumped)

This bellow code will generate Aborted (core dumped) at last line. code: #include <stdio.h> #include <malloc.…

c malloc runtime-error coredump backtrace
Dynamic array in C — Is my understanding of malloc and realloc correct?

I am learning how to create dynamic 1D arrays in C. The code below tries to do the following: Using …

c arrays malloc realloc
What is the name of the header file that contains the declaration of malloc?

What is the name of the header file that contains the declaration of the malloc() function in C and C++?

c++ c malloc
Allocate memory and save string in c

I was wondering why the following code isnt't working int main(int argc, char **argv) { char *test = (char*) malloc(12*sizeof(…

c string malloc free
Why malloc+memset is slower than calloc?

It's known that calloc is different than malloc in that it initializes the memory allocated. With calloc, the memory is …

c malloc
Malloc segmentation fault

Here is the piece of code in which segmentation fault occurs (the perror is not being called): job = malloc(sizeof(…

c segmentation-fault malloc stack-overflow buffer-overflow
How can I allocate memory and return it (via a pointer-parameter) to the calling function?

I have some code in a couple of different functions that looks something like this: void someFunction (int *data) { data = (…

c pointers malloc
alloc, malloc, and alloca — What's the difference?

I was under the impression that alloc in Objective-C (when we invoke [anyObject alloc] is actually implementing C function malloc …

c memory memory-management malloc alloca