Whats the difference between:

pp = malloc(m*sizeof(int)) <--- I understand this

and

pp = **int malloc (m*sizeof(int)) <--- but not this ?

Recommended Answers

All 2 Replies

The second example is illegal syntax, maybe you meant this? pp = (int**) malloc (m*sizeof(int)) The first example is ok in C language but not in C++, which requires the return value of malloc() to be typecast to the appropriate type of variable. Other than the typecast they both are identical.

And BTW you shouldn't expect people to respond so quickly to a question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.