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
Unary Minus Operator( Negation) This operand can be used to negate the value of a variable. It is also used to state a negative number, here a minus(-) sign is prefixed to the

example of program to add two number

Write a program that illustrate  Macros with Arguments? Macros is able to also have arguments, just as functions can. #define AREA(x)(3.14*x*x) Then at any time the prepr

The program will ask the user to enter: '1' to List the cities(and their state abbrev)  from largest to smallest (by their population) with their population '2'  to List the

create a program to populate the first array then the odd number is the second array and get the sum of the second array.

What is a newline escape sequence? - A newline escape sequence is signified by the \n character. - It is used to insert a new line whereas displaying the output data. - T


Why shouldn't Matrix class's interface look like an array-of-array? A: Some people build a Matrix class that has an operator[] that returns a reference to an Array object (or po

(a) Write a procedure called (area-of-rectangle h w) that computes the area of a rectangle of height h and width w. (b) Write a procedure called (area-of-circle r) that computes

Define Commonly Used Built-in Library Functions? Comprise opened a file pointer you will desire to use it for either input or output. The C language supplies a set of functions