Define difference among new & malloc?, C/C++ Programming

Both malloc & new functions are utilized for dynamic memory allocations & the basic difference is: malloc need a special "typecasting" while it allocates memory for eg. if the pointer utilized is the char pointer then after processor allocates memory then it allocated memory required to be typecasted to char pointer for example (char*).however new does not needs any typecasting. Also, free is the keyword utilized to free the memory whereas using malloc & delete the keyword to free memory whereas using new, or else it will lead the memory leak.

 

Posted Date: 3/16/2013 3:21:08 AM | Location : United States







Related Discussions:- Define difference among new & malloc?, Assignment Help, Ask Question on Define difference among new & malloc?, Get Answer, Expert's Help, Define difference among new & malloc? Discussions

Write discussion on Define difference among new & malloc?
Your posts are moderated
Related Questions
Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

In which condition a template a better solution than a base class? A: While you are designing a generic class to contain or manage objects of other types, while the format & beh

program that generate university statistical bar graph using 3d function

Inheritance and Reuse Consider a car manufacturing company. When they require building a new car, they have two choices. They can start from the scratch, or they can change an

Explain the Command Line Parameters? The Command line arguments are parameters supplied to a program from the operating system. These arguments are parameters accepted to main

a) Implement a binomial tree class with a method that calculates the value of an option passed in to the class. The binomial tree should not rely on specific features of the differ

Program to define an array in c: Write a program to define an array and print the value of array. void main() { int a[10]={0,11,21,34,44,75,46,57,88,89},i,j,k; clr

#include stdio.h   struct  complex   {   float real;   float imag;   };   struct complex complexadd(struct complex,struct  complex);   void main()     {          Date: 26

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Described the difference among "new" and "operator new" ? A:"operator new" works such as malloc.