Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
C Programming

malloc() in C

Allocate uninitialized bytes with malloc.

malloc() in C — a practical guide to C malloc with clear examples you can reuse in real projects.

C Programming Tutorial Series (64/102). Prefer one article? Read the complete C programming tutorial.

Short description

Always check for NULL on failure.

malloc

int *a = malloc(10 * sizeof *a);
if (!a) {
    perror("malloc");
    return 1;
}
free(a);

Leave a reply

Your email address will not be published. Required fields are marked *