Read and learn; if you do not understand ask smart questions.
realloc - C++ Reference
Type: Posts; User: stahta01
Read and learn; if you do not understand ask smart questions.
realloc - C++ Reference
test = realloc (test, sizeof(char));
You allocate ONLY a single char then you over-write your program stack; you are lucky your program ran without crashing.
I suggest re-reading the docs...