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

Differentiate between late binding and early binding. What are the advantages of early binding?

1 Answers  


Write a Program to find the largest of 4 no using macros.

1 Answers  


Why is c++ a mid-level programming language?

1 Answers  


What is pointer to array in c++?

1 Answers  


What do you mean by C++ access specifiers ?

1 Answers  


What is the type of this pointer in c++?

1 Answers  


How come you find out if a linked-list is a cycle or not?

1 Answers  


Can a list of string be stored within a two dimensional array?

1 Answers  


What issue do auto_ptr objects address?

2 Answers  


What is DlgProc?

1 Answers   C DAC,


Write about the scope resolution operator?

1 Answers  


Why is c++ so fast?

1 Answers  


Categories