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


Please Help Members By Posting Answers For Below Questions

What is the advantage of an external iterator.

577


What is an overflow error?

626


What are formatting flags in ios class?

613


Explain the advantages of using friend classes.

594


How is modularity introduced in C++?

771






Explain what data encapsulation is in c++?

579


Can a list of string be stored within a two dimensional array?

580


Why is main function important?

590


Is multimap sorted c++?

560


Describe friend function & its advantages.

719


What sorting algorithm does c++ use?

604


What is function prototyping? What are its advantages?

597


Name the debugging methods that are used to solve problems?

585


Can there be at least some solution to determine the number of arguments passed to a variable argument list function?

608


In a function declaration, what does extern mean?

640