what is the behaviour of C and C++ compiler for the below
statements.
int *p;
p = malloc(100);

Is the behaviour same ? or different ?

Answer Posted / pramodsingh_45

In "C" the implicit typecasting will be done from void* to
int* but in C++ we need to do explicit typecasting.

so in C++
p = (int*)malloc(100);
but in C
p = malloc(100) will also work.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain Text Manipulation Routines?

724


What is microsoft c++ redistributable 2013?

665


What is stl containers in c++?

673


What does catch(…) mean?

721


What are c++ data types?

732






What's the order in which the local objects are destructed?

918


Write a Program to find the largest of 4 no using macros.

686


What do you mean by delegate? Can a user retain delegates?

604


Can you please explain the difference between static and dynamic binding of functions?

647


why is iostream::eof inside a loop condition considered wrong?

679


What is meant by const_cast?

759


Describe friend function & its advantages.

803


What is the best c++ compiler?

679


In what situations do you have to use initialization list rather than assignment in constructors?

719


What are references in c++?

764