6

I'm using visual studio to write a c code.

This is the malloc code line i was told to use:

root = (Coor)malloc(sizeof(Coor));

It doesn't let me use it for the following error:

identifier not found

Can anyone tell me why it happens and how to fix it?

Thanks,

3
  • 3
    Care to finish that error message with the identifier name claimed to not be found??
    – WhozCraig
    Commented Jun 22, 2013 at 18:43
  • 1
    Stupid me… I didn't see the library wan't included. Thanks anyway Commented Jun 22, 2013 at 18:45
  • 2
    Your code looks broken anyway. Allocating sizeof(Coor) bytes and then converting the result to Coor makes no sense whatsoever. Either convert to Coor * or allocate sizeof <derefernced Coor> (of Coor is a pointer type). Moreover, casting the result of malloc in C can only hide erros, but serves no other meaningful purpose. Commented Jun 22, 2013 at 18:50

1 Answer 1

10

Please check if you have included <stdlib.h> and <malloc.h>.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.