LogiQuest
Back to Memory Allocation
11

What will be the output of the program?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    char *s = malloc(6);
    if (!s) return 1;
    strcpy(s, "heap!");
    printf("%s\n", s);
    free(s);
    return 0;
}
Easy

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.