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
Answer / venu
we should explicitly typecast. Otherwise it is give a
compilation error.
| Is This Answer Correct ? | 3 Yes | 0 No |
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 |
What is the main function c++?
What is the difference between interpreters and compilers?
How did c++ start?
What is a .lib file in c++?
How is an Abstract Base Class(ABC) related to an "Abstract Data Type" (ADT)
Mention the ways in which parameterized can be invoked.
Write a C++ program to sort digits of all the 4 digit number and display the sorted 4 digit number
What will happen if I allocate memory using "new" and free it using "free" or allocate sing "calloc" and free it using "delete"?
How do I write a c++ program?
Does a derived class inherit or doesn't inherit?
how many controls can we place on single form.
What is math h in c++?