C Programming - Memory Allocation - Discussion
Discussion Forum : Memory Allocation - General Questions (Q.No. 3)
3.
How will you free the memory allocated by the following program?
#include<stdio.h>
#include<stdlib.h>
#define MAXROW 3
#define MAXCOL 4
int main()
{
int **p, i, j;
p = (int **) malloc(MAXROW * sizeof(int*));
return 0;
}
Discussion:
25 comments Page 2 of 3.
Vahitha said:
1 decade ago
What is the difference between alloc(), malloc(), calloc(), please give the clear idea?
Anju said:
1 decade ago
Can you please explain what is the meaning of
p = (int **) malloc(MAXROW * sizeof(int*));
p = (int **) malloc(MAXROW * sizeof(int*));
Jhansi said:
1 decade ago
In that program I want to meaning of p=(int**)malloc(MAXROW*sizeof(int*)).
CHINNA DURAI.S said:
1 decade ago
Why we use C program in mostly?
Siddu said:
1 decade ago
**p means?
Abhishek said:
1 decade ago
It is a pointer to a pointer, means it keeps the address of a pointer variable.
Ex: int *q, **p;
Then p = &q;
Ex: int *q, **p;
Then p = &q;
Amit said:
10 years ago
Please explain me how malloc works?
Abhi said:
9 years ago
What is the advantage of malloc and calloc?
Darshan kg said:
9 years ago
Malloc allocates a single block of memory but calloc allocates multiple blocks of memory. For calloc block, initial value will be zero.
Emanuel said:
9 years ago
I don't understand the casting (int**). The malloc function gives an address of memory where you can put an integer value, i.e., it is a pointer to an integer. How it can help a cutting that it points to a pointer to an integer. It, indeed, only a pointer to an integer?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers