the difference between new and malloc

Answer Posted / sanish joseph

both malloc and new functions are used for dynamic memory
allocations and the basic difference is: malloc requires a
special "typecasting" when it allocates memory for eg. if
the pointer used is the char pointer then after the
processor allocates memory then this allocated memory needs
to be typecasted to char pointer i.e (char*).but new does
not requires any typecasting. Also, free is the keyword used
to free the memory while using malloc and delete the keyword
to free memory while using new, otherwise this will lead the
memory leak.

Is This Answer Correct ?    13 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the important feature of inheritance?

637


What does sksksk mean in text slang?

1537


write a program that takes input in digits and display the result in words from 1 to 1000

1991


What is the full form of oops?

612


What does and I oop mean?

618






write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory

2765


What is variable example?

599


What is the difference between procedural programming and oops?

559


How do you achieve polymorphism?

618


What is object in oop?

683


What is encapsulation in oop?

609


can we make game by using c

3433


What is encapsulation in oops?

541


What is coupling in oop?

600


What does <> mean pseudocode?

624