[Solved] Valgrind runs infinitely with realloc but code works
It is always easier to divide program into logical bits and place them in functions. char *addToBuff(char *buff, int ch, size_t *size) { //working on local variable buff. No need for a temporary variable buff = realloc(buff, *size + 1); if(buff) { buff[*size] = ch; *size += 1; } return buff; } char *readToBuff(FILE *fi, … Read more