You're almost there. Now just use memmove
to move the memory left to the new line.
char str[255];
char* ptrchr;
char* end;
gets(str); // DANGEROUS! consider using fgets instead
end = (str + strlen(str));
while( (ptrch=strstr(str, " ")) != NULL)
{
memcpy(ptrch, "\n", 1);
memmove(ptrch + 1, ptrch + sizeof(" ") - 1, end-ptrchr);
}
printf("%s", str);