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 void pointer in c++ with example?
Explain deep copy and a shallow copy?
What are the two shift operators and what are their functions?
How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?
Reverse the Linked List. Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL
List down the guideline that should be followed while using friend function.
What does iomanip mean in c++?
When should overload new operator on a global basis or a class basis?
Difference between strdup and strcpy?
Explain the isa and hasa class relationships. How would you implement each?
why is iostream::eof inside a loop condition considered wrong?
What is the oldest programming language?
What is expression parser in c++
Are vectors faster than arrays?
What are the important differences between c++ and java?