what is the behaviour of C and C++ compiler for the below
statements.
int *p;
p = malloc(100);
Is the behaviour same ? or different ?
Answer Posted / 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 View All Answers
Which is best c++ or java?
What are libraries in c++?
Write an algorithm that determines whether or not an almost complete binary tree is a heap.
Specify some guidelines that should be followed while overloading operators?
What is c++ used for in games?
Differentiate between an array and a list?
How do you declare a set in c++?
How a macro differs from a template?
Is multimap sorted c++?
How can I learn c++ easily?
What does h mean in maths?
Where the memory to the static variables is allocated?
Differentiate between realloc() and free().
How can we check whether the contents of two structure variables are same or not?
Explain the term memory alignment?