>what do you mean here?
The pointer p may not point to valid memory after the call to realloc, so the printf call is unpredictable. It may work as expected or invoke undefined behavior. The only way to ensure that this doesn't happen is to reassign p before calling printf:Code:int *a = malloc(5 * sizeof *a); int *p = &a[2]; /* Assuming success */ a = realloc(a, 10 * sizeof *a); printf("%d\n", *p);
>are you the one who will judje our solutions? Do you have that much time? OR are you going to get paid for that?Code:int *a = malloc(5 * sizeof *a); int *p = &a[2]; /* Assuming success */ a = realloc(a, 10 * sizeof *a); p = &a[2]; printf("%d\n", *p);
I wouldn't mind getting paid.But I'll find the time to judge.



LinkBack URL
About LinkBacks
But I'll find the time to judge. 


