To replace the entire new char string with spaces, use:
char *pch = strstr(myStr, "\n"); while(pch != NULL) { strncpy(pch, " ", 1); pch = strstr(myStr, "\n"); }
To remove the first occurrence of a new char string in a string, use:
char *pch = strstr(myStr, "\n"); if(pch != NULL) strncpy(pch, "\0", 1);
source share