1 Replies - 1662 Views - Last Post: 22 June 2011 - 02:18 PM Rate Topic: -----

#1 reynaud0000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 37
  • Joined: 19-June 11

passing arg 1 of `free' makes pointer from integer without a cast

Posted 22 June 2011 - 02:06 PM

void delete(){   
    
     int dlt;
     int p = ptr->id;
     printf("delete ID: ");
     scanf("%d" ,dlt);
     if (dlt == p){
          free (ptr->id);
     }   
     system("PAUSE");   
}


Can anyone tell me why it gives me this error

passing arg 1 of `free' makes pointer from integer without a cast

This post has been edited by reynaud0000: 22 June 2011 - 02:07 PM

Is This A Good Question/Topic? 0
  • +

Replies To: passing arg 1 of `free' makes pointer from integer without a cast

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2089
  • View blog
  • Posts: 3,179
  • Joined: 21-June 11

Re: passing arg 1 of `free' makes pointer from integer without a cast

Posted 22 June 2011 - 02:18 PM

You get that error because ptr->id is an integer and you're passing it to free, which wants a pointer, not an integer (specifically you should only ever pass pointers to memory which has been allocated by malloc to free).

Another error in your code is that the second argument to scanf should be a pointer to an integer, not an integer. You probably want to pass &dlt here instead of dlt.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1