0
Does anyone knows about the function calloc in c ? It seem that it does not behave as it is supposed.
I have a pointer *ptr on an array of a structure with two members : an int and ant int *t. when I apply calloc on *ptr to cet more space, the contents of each existent *t change.
2 odpowiedzi
0
I believe it is because when you use calloc it will not only increase the pointer, it will create a new memory address of the desired size with all the bytes zeroed.
If this is the case, you can use memcpy to pass the data from the old pointer to the new pointer.
0
sorry it was realloc not calloc