Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Which is best c++ or java?

1085


What are libraries in c++?

1070


Write an algorithm that determines whether or not an almost complete binary tree is a heap.

3921


Specify some guidelines that should be followed while overloading operators?

1209


What is c++ used for in games?

1171


Differentiate between an array and a list?

1180


How do you declare a set in c++?

957


How a macro differs from a template?

1179


Is multimap sorted c++?

1008


How can I learn c++ easily?

1084


What does h mean in maths?

1218


Where the memory to the static variables is allocated?

1061


Differentiate between realloc() and free().

1056


How can we check whether the contents of two structure variables are same or not?

1073


Explain the term memory alignment?

1240