Tag Archives: C-Dynamic Memory Allocation

In this article, if memory allocation using new is failed in C++ then how it should be handled? When an object of a class is… Read More
As we know that new is used to create memory dynamically and it is the programmer’s responsibility to delete the memory location explicitly and it… Read More
Data Types Data-type in simple terms gives us information about the type of data. Example, integer, character, etc. Data-types in C language are declarations for the… Read More
Pre-requisite: Dynamic memory allocation in C The “malloc” or “memory allocation” method is used to dynamically allocate a single large block of memory with the… Read More
Memory leakage occurs in C++ when programmers allocates memory by using new keyword and forgets to deallocate the memory by using delete() function or delete[]… Read More
Prerequisite: How to dynamically allocate a 2D array in C? Double pointer: A pointer pointing to another pointer is known as a Double pointer. To… Read More
Dereferencing an unknown memory location : C programmers mostly use scanf() function to take input, but sometimes a small mistake can bring a bug or… Read More
Core Dump/Segmentation fault is a specific kind of error caused by accessing memory that “does not belong to you.”   When a piece of code tries… Read More
Consider the following program, where are i, j and k are stored in memory? filter_none edit close play_arrow link brightness_4 code int i; int main()… Read More
What is the problem with following code? filter_none edit close play_arrow link brightness_4 code #include<stdio.h> int main() {     int *p = (int *)malloc(sizeof(int));        p… Read More
Which of the following is true? (A) “ptr = calloc(m, n)” is equivalent to following ptr = malloc(m * n); (B) “ptr = calloc(m, n)”… Read More
What is the return type of malloc() or calloc() (A) void * (B) Pointer of allocated memory type (C) void ** (D) int * Answer:… Read More
Which of the following is/are true (A) calloc() allocates the memory and also initializes the allocates memory to zero, while memory allocated using malloc() has… Read More
Output? filter_none edit close play_arrow link brightness_4 code # include<stdio.h> # include<stdlib.h>     void fun(int *a) {     a = (int*)malloc(sizeof(int)); }     int main() {… Read More
Consider the following three C functions : filter_none edit close play_arrow link brightness_4 code [PI] int * g (void)  {    int x= 10;    return (&x); … Read More