[Solved] Problem of a string read in function system() (probably due to a bad malloc) [closed]

chain1 = (char *) malloc(5*sizeof(char*) + 1); This will allocate enough space for five character pointers plus an extra byte. A pointer is not the same as a character, it tends to be either four or eight bytes currently but can actually be any size. You probably want sizeof(char) but, since that’s always 1, you … Read more