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

What is helper in c++?

0 Answers  


Which is better turbo c++ or dev c++?

0 Answers  


List out some of the OODBMS available?

1 Answers  


How java is different from c and c++?

0 Answers  


Does there exist any other function which can be used to convert an integer or a float to a string?

0 Answers  






What are guid? Why does com need guids?

0 Answers  


Describe linked list using C++ with an example.

0 Answers  


What happens if a pointer is deleted twice?

0 Answers   Flextronics,


What methods can be overridden in java?

0 Answers  


How many namespaces are there in c++?

0 Answers  


How is objective c different from c++?

0 Answers  


What are the storage qualifiers?

0 Answers  


Categories