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
What is the most powerful coding language?
How a new element can be added or pushed in a stack?
Can I create my own functions in c++?
Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)
In what situations do you have to use initialization list rather than assignment in constructors?
What can I safely assume about the initial values of variables which are not explicitly initialized?
What programming language should I learn first?
an integer constant must have atleast one a) character b) digit c) decimal point
What is the meaning of string in c++?
What are the benefits of c++?
Difference between strdup and strcpy?
What is a memory leak c++?
What is the history of c++?
What happens if a pointer is deleted twice?
Can comments be nested?