free geoip

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how we used the 1-calloc Function 2- malloc Function 3- free () 4- realloc Function i
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#1
Define that how we used the 1-calloc Function 2- malloc Function 3- free () 4- realloc Function in C and C++ 2012- 14

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply
#2
Calloc malloc and realloc are use for dynamic memory allocation. Mainly there are two types calloc and malloc. Realloc is the provide the litter variation in malloc.

calloc take two argument i.e. calloc(m,n) where first argument is how much space you require in term of number of elements and 2nd argument is space in term of size of each element
For example

calloc(1000,sizeof(int));

where 1000 is total space that is allocated from heap and it is of size integer.
The main benefit of doing memory allocation through calloc that memory is automatically initialized with 0.

malloc take one argument i.e. malloc(n) wher n is number of bytes required.
For example

malloc(1000*(sizeof(int)));

Where again 1000 require space that is allocated from heap and it is multiplied with integer.

If a pointer has already been allocated memory using malloc and later this allocated memory needs to be expanded for some reason, the realloc function is used. It will add the consecutive memory spaces to the existing if available, otherwise it will allocate whole new space for the same pointer. free is use to de-allocation the memory which we allocation for our use.

As I already told you that alloc malloc and realloc are use for dynamic memory allocation once you allocation memory using any of the method, you must use free to de-allocate the memory.

Yes you are right these function are from C but C++ also support these functions.

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how many malloc ,calloc and realloc take arguments in c++ Vuhelper 0 5,656 06-20-2012, 08:57 PM
Last Post: Vuhelper
  why we use inline function if there are simple function available, or what is the spa Vuhelper 0 22,020 05-31-2012, 01:51 AM
Last Post: Vuhelper
  Default Function Argument with example Vuhelper 0 13,383 05-31-2012, 01:47 AM
Last Post: Vuhelper
  What is the difference among calloc function ,malloc function and recalloc function? Vuhelper 0 34,643 05-31-2012, 01:46 AM
Last Post: Vuhelper
  What is Function Overloading in C++ Vuhelper 0 5,447 05-31-2012, 01:45 AM
Last Post: Vuhelper
  offline function in C++ Vuhelper 0 3,678 05-31-2012, 01:42 AM
Last Post: Vuhelper
  i take input from getchar(); function in program in C++ 2012 Vuhelper 0 3,044 05-31-2012, 01:40 AM
Last Post: Vuhelper
  What are the function of IO ports in C++ Vuhelper 0 3,646 05-31-2012, 01:27 AM
Last Post: Vuhelper
  Argc(argument count) and argv(argument value) are used in main function Vuhelper 0 2,063 01-04-2012, 10:42 PM
Last Post: Vuhelper
  stack during function call in C++ 2011 Vuhelper 0 2,063 11-05-2011, 05:05 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support