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
A palindrome is a string that reads the same from the both the ends. Given a string S convert it to a palindrome by doing character replacement. Your takes is to convert S to palin

i want a c or c++ code for solving transportation problem using modified distribution method

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

(a) Write a fragment of code that declares a variable colSp of type ColourSpot, and then moves it to the point (3, -4), and sets its colour to Green. (b) A function QU8 is speci

Write a C program to input three real numbers and  print them out as follows : The first variable is ....... and the second one is ...... The last variable is .......... T

I need vsti program Project Description: Knowledge of vsti programs, and music is a plus, ex: nexus I will input the sounds I just need the interface built Skills required

Converting Base Type to Class Type (char to string)   class String { char *name; int length; public: String(void) {length =0; name = new char[length+1];

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b


Determine the types of Container class Container class can be of 2 types: - Heterogeneous container - Here container class comprise a group of mixed objects - Homogeneou