Skip to content

Tag Archives: C-Dynamic Memory Allocation

Output?  C # include<stdio.h> # include<stdlib.h>    void fun(int *a) {     a = (int*)malloc(sizeof(int)); }    int main() {     int *p;     fun(p);     *p = 6;… Read More
Consider the following three C functions : [PI] int * g (void)  {    int x= 10;    return (&x);  }        [P2] int * g (void) … Read More
The most appropriate matching for the following pairs (GATE CS 2000) X: m=malloc(5); m= NULL;        1: using dangling pointers Y: free(n); n->value=5;         2: using uninitialized… Read More
Question: How to deallocate dynamically allocate memory without using “free()” function.  Solution: Standard library function realloc() can be used to deallocate previously allocated memory. Below… Read More
  A typical memory representation of a C program consists of the following sections. Text segment  (i.e. instructions) Initialized data segment  Uninitialized data segment  (bss)… Read More
Consider the following prototype of free() function which is used to free memory allocated using malloc() or calloc() or realloc(). void free(void *ptr); Note that… Read More
Size of dynamically allocated memory can be changed by using realloc(). As per the C99 standard: void *realloc(void *ptr, size_t size); realloc deallocates the old… Read More
Pre-requisite: Dynamic Memory Allocation in C using malloc(), calloc(), free() and realloc()The functions malloc() and calloc() are library functions that allocate memory dynamically. Dynamic means… Read More
Memory leak occurs when programmers create a memory in heap and forget to delete it. Memory leaks are particularly serious issues for programs like daemons and servers which by definition never terminate.

Start Your Coding Journey Now!