I
Igal
hay, i have this werid problem with my book adding function, this how
it looks
book* AddBook(book *bp, unsigned *size) {
....
//then i use realloc to allocate space for the new item in the bp
pointer
bp = (book*)realloc(bp, sizeof(book));
....
}
when i do this, the next them is added in this right space. but let's
say *bp hold 2 book type items, first item will be ok, second one will
get garbage content, then the third item (the new reallocated one)
will get the new data.
i just have no idea will the last item gets corruped, this also
happens with more items in array.
i know that to use linked lists is a lot better solution, but i still
dunno how to use them right just yet.
it looks
book* AddBook(book *bp, unsigned *size) {
....
//then i use realloc to allocate space for the new item in the bp
pointer
bp = (book*)realloc(bp, sizeof(book));
....
}
when i do this, the next them is added in this right space. but let's
say *bp hold 2 book type items, first item will be ok, second one will
get garbage content, then the third item (the new reallocated one)
will get the new data.
i just have no idea will the last item gets corruped, this also
happens with more items in array.
i know that to use linked lists is a lot better solution, but i still
dunno how to use them right just yet.