View Single Post
Old 03-24-2005, 05:14 AM   #6 (permalink)
santechz
 
Newb Techie

Join Date: Mar 2005

Posts: 3

santechz

Default

Hey!
malloc() returns the address of a requested byte(s). you can only request for bytes. Please do try the snippet and see it for your self:
char *ptr1 = (char *) malloc(6*sizeof(char)); //assume 1char=1byte
char *ptr2=(char*) malloc(sizeof(char));//

now there will be either 8 byte difference between ptr1 (not &(ptr1)) and ptr2. i.e. ptr2-ptr1=8. and the "gap" between the 1'st requested(6 bytes) and the successive request will be 2 bytes....
santechz is offline