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

Is string data type in c++?

0 Answers  


What is cloning?

1 Answers  


What is the use of setprecision in c++?

0 Answers  


How to get the current position of the file pointer?

0 Answers  


What is data types c++?

0 Answers  






How are virtual functions implemented in c++?

0 Answers  


Explain class invariant.

0 Answers  


How do you declare A pointer to a function which receives nothing and returns nothing

0 Answers  


If a base class is an adt, and it has three pure virtual functions, how many of these functions must be overridden in its derived classes?

0 Answers  


Can a new be used in place of old mallocq? If yes, why?

0 Answers  


What is "mutable" keyword?

2 Answers   Infosys, Teradata,


What is the purpose of templates in c++?

0 Answers  


Categories