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,

Nimrod Shai
  • 1,149
  • 13
  • 26
  • 3
    Care to finish that error message with the ***identifier*** name claimed to not be found?? – WhozCraig Jun 22 '13 at 18:43
  • 1
    Stupid me… I didn't see the library wan't included. Thanks anyway – Nimrod Shai Jun 22 '13 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 ` (of `Coor` is a pointer type). Moreover, casting the result of `malloc` in C can only hide erros, but serves no other meaningful purpose. – AnT stands with Russia Jun 22 '13 at 18:50

1 Answers1

10

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

Mat
  • 202,337
  • 40
  • 393
  • 406
Steven Huang
  • 490
  • 4
  • 16