Question : remove string from string c
Answered by : godwinkvg
#include <string.h>
char *strremove(char *str, const char *sub) { size_t len = strlen(sub); if (len > 0) { char *p = str; while ((p = strstr(p, sub)) != NULL) { memmove(p, p + len, strlen(p + len) + 1); } } return str;
}
Source : https://stackoverflow.com/questions/47116974/remove-a-substring-from-a-string-in-c | Last Update : Tue, 05 Jan 21
Question : delete string function in c
Answered by : wideeyed-weevil-1zox47lrkimo
/*The logic behind the function is to copy and place the ending part of string
along with the deliminator '\0' to the position from where you want the
"no_of_char" number of characters removed*/
void delchar(char *string,int starting_pos, int no_of_char)
{ if (( starting_pos + no_of_char - 1 ) <= strlen(x) ) { strcpy(&x[starting_pos-1],&x[starting_pos + no_of_char-1]); puts(x); }
}
Source : https://www.programming9.com/programs/c-programs/213-c-program-delete-characters-from-string | Last Update : Sun, 28 Jun 20