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 |
How are the features of c++ different from c?
How do you initialize a string in c++?
What is a concrete class?
Explain function overloading and operator overloading.
What is name mangling?
Explain class invariant.
what does the following statement mean? int (*a)[4]
Why main function is special in c++?
Define pointers?
What is vectorial capacity?
What and all can a compiler provides by default?
Can the operator == be overloaded for comparing two arrays consisting of characters by using string comparison?