[Solved] realloc fails when printf is in code / weird chars

Your code exhibits undefined behaviour because you passed a non-static, uninitialised pointer to realloc whose contents were indeterminate. From C11, Memory Management Functions: The realloc function deallocates the old object pointed to by ptr and returns a pointer to a new object that has the size specified by size. ….if ptr does not match a … Read more