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

Will a catch statement catch a derived exception if it is looking for the base class?

0 Answers  


What is general form of pure virtual function? Explain?

0 Answers  


What is new in c++?

0 Answers  


Explain how functions are classified in C++ ?

0 Answers  


What is a storage class? Mention the storage classes in c++.

0 Answers  






What is pure virtual function?

0 Answers  


Is it possible to use a new for the reallocation of pointers ?

0 Answers  


What is the difference between global variables and local variable

0 Answers  


Explain what are mutator methods in c++?

0 Answers  


Is java based off c++?

0 Answers  


What is the operator in c++?

0 Answers  


What is static in c++?

0 Answers  


Categories