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 a class template in c++?

0 Answers  


What is basic if statement syntax?

0 Answers  


Is map sorted c++?

0 Answers  


How many ways are there to initialize an int with a constant?

1 Answers  


How do you write a function that can reverse a linked-list?

0 Answers  






please help to write the code of chess game in c++??????????

1 Answers   NEC,


Why was c++ created?

0 Answers  


What are the uses of static class data?

0 Answers  


what is scupper?

0 Answers  


What is the difference between a baller and a reference in C++?

0 Answers  


What is a c++ vector?

0 Answers  


Define the operators that can be used with a pointer.

0 Answers  


Categories