What is difference between new and malloc?

Answers were Sorted based on User's Feedback



What is difference between new and malloc?..

Answer / harsh

the difference between malloc and new is just that when a
variable is declared using malloc, it requires type casting
while new operator whenever used does not type cast by
itself as there is no need for the variable to be typecasted
when used with new operator

Is This Answer Correct ?    11 Yes 0 No

What is difference between new and malloc?..

Answer / shivi jain

new and delete are C++ specific features. They didn't exist in C. malloc is the old school C way to do things. Most of the time, you won't need to use it in C++.

malloc allocates uninitialized memory. The allocated memory has to be released with free.
calloc is like malloc but initializes the allocated memory with a constant (0). It needs to be freed with free.
new initializes the allocated memory by calling the constructor (if it's an object). Memory allocated with new should be released with delete (which in turn calls the destructor). It does not need you to manually specify the size you need and cast it to the appropriate type. Thus, it's more modern and less prone to errors.

Is This Answer Correct ?    7 Yes 0 No

What is difference between new and malloc?..

Answer / vivin

malloc is a dynamic memory allocation for pointers in C language. It stands for memory allocation. It is used to allocate continuous block of memory.

Is This Answer Correct ?    4 Yes 0 No

What is difference between new and malloc?..

Answer / vivin

new is a operator used for memory allocation in c++ & java

Is This Answer Correct ?    3 Yes 0 No

What is difference between new and malloc?..

Answer / devi

In C the malloc is used to allocate the memory space


In C++ the new operator is used to allocate the memory space

Is This Answer Correct ?    2 Yes 2 No

What is difference between new and malloc?..

Answer / amri

When we use macro its need typecasting but in new not need of typecasting.

new is a operator.

Is This Answer Correct ?    0 Yes 3 No

What is difference between new and malloc?..

Answer / sanjeevkumar.v

malloc --it mean memmory allocation .it will be.crete a
memory from a element



NEW--- newly crate a program are crete a memory allocation

Is This Answer Correct ?    1 Yes 10 No

Post New Answer

More OOPS Interview Questions

write a C++ program for booking using constructor and destructor.

0 Answers   HAL,


What is oops in simple words?

0 Answers  


JAVA is FULLY OBJECT ORIENTED PROGRAMING LANGUAGE?

3 Answers  


What is command routing in MFC

1 Answers   GE,


How to overload new operator in c++

2 Answers  






why to use operator overloading

3 Answers  


#include <iostream> using namespace std; int main() { int a = 2; int c[5][5]; for (int x=0;x<5;x++) { for (int y=0;y<5;y++) { c[x][y] = x*y; } } cout << c[a][c[1][4]]; }

2 Answers   TCS, Wipro,


What are the three main types of variables?

0 Answers  


How can you overcome the diamond problem in inheritance?

0 Answers   NIIT,


In multilevel inheritance constructors will be executed from the .... class to ... class

2 Answers   ABCO, TCS,


why freind function takes more parameter than normal member function in c++?

1 Answers   IBM,


given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy

0 Answers   DELL,


Categories