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 difference between "calloc" and "malloc"?
Write any small program that will compile in "C" but not in "C++"
What does it mean to declare a member variable as static?
Explain about Virtual Function in C++?
Why seem interrupt handlers as member functions to be impossible?
What is the identity function in c++? How is it useful?
What are the differences between a struct and a class in C++?
What is a class definition?
What is the basic structure of a c++ program?
What are the two types of comments, and how do they differ?
What is the difference between cin.read() and cin.getline()?
What are the differences between public, private, and protected access?
12 Answers IBM, Oracle, Wipro,