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

Is the behaviour same ? or different ?

Answers were Sorted based on User's Feedback



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

Answer / venu

we should explicitly typecast. Otherwise it is give a
compilation error.

Is This Answer Correct ?    3 Yes 0 No

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

Answer / 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

More C++ General Interview Questions

Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

4 Answers   Webyog,


How to declaring variables in c++?

0 Answers  


Where Malloc(), Calloc(), and realloc() does get memory?

0 Answers  


What is the advantage of an external iterator.

0 Answers  


What is the purpose of ios::basefield in the following statement?

0 Answers  






What is nested class in c++?

0 Answers  


Differentiate between a deep copy and a shallow copy?

1 Answers  


What is the best book for c++ beginners?

0 Answers  


Will this c++ program execute or not?

0 Answers  


What is a friend function in c++?

0 Answers  


What is compilation?

1 Answers   Datamatics, TCS,


What do the keywords volatile and mean mutable?

0 Answers  


Categories