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 |
Is string data type in c++?
What is cloning?
What is the use of setprecision in c++?
How to get the current position of the file pointer?
What is data types c++?
How are virtual functions implemented in c++?
Explain class invariant.
How do you declare A pointer to a function which receives nothing and returns nothing
If a base class is an adt, and it has three pure virtual functions, how many of these functions must be overridden in its derived classes?
Can a new be used in place of old mallocq? If yes, why?
What is "mutable" keyword?
What is the purpose of templates in c++?