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 c++ prototype?
Explain what you mean by a pointer.
What does new do in c++?
What is ostream in c++?
What is meant by entry controlled loop? What all C++ loops are exit controlled?
What is bubble sort c++?
What are the different types of comments allowed in c++?
How size of a class can be calulated?
Is c++ proprietary?
Are strings immutable in c++?
What can c++ be used for?
What is long in c++?