0

Hello everyone this is my first question so if I do something wrong ,please forgive me.

I have been trying to allocate memory for the struct I have written.definition as follows;

struct newstruct* temp1;
temp1 = malloc(1*sizeof(struct newstruct));

whenever I tried to allocate memory like this I always get the "[Warning] incompatible implicit declaration of built-in function 'malloc'" warning. I don't understand if my definition wrong or I am missing anything.

  • 2
    You need to read the manual for `malloc` and discover which header declares it. – Kerrek SB May 13 '15 at 00:50
  • @KerrekSB and upvoters: if he is asking this question he is literally just getting started. He doesn't need to read the reference manual, a notoriously tedious and dry technical dump, he needs to get better at [Googling C errors](https://encrypted.google.com/search?hl=en&q=[Warning]%20incompatible%20implicit%20declaration%20of%20built-in%20function%20%27malloc%27). – user1717828 May 13 '15 at 03:07

1 Answers1

0

Try adding:

#include <stdlib.h>

to your includes.

mikyra
  • 10,077
  • 1
  • 40
  • 41