Ansi c does not provide the string replace function. Some functions are implemented on the Internet, but most of them have a problem: not all replace.
For example, this is a test to test string replacing.
If you want to replace test with example, the result of all replace is: this is a example to example string replacing.
Many implementations on the Internet only need to find a result and return it.
Here I have written a function for all replicas:
Char * strrepl (const char * SRC, char * DST, size_t dst_size, const char * search, const char * replace_with) {<br/> char * replace_buf = (char *) malloc (dst_size); <br/> If (replace_buf) {<br/> replace_buf [0] = 0; <br/> char * P = (char *) SRC; <br/> char * Pos = NULL; <br/> while (Pos = strstr (p, search ))! = NULL) {<br/> size_t n = (size_t) (POS-P); <br/> strncat (replace_buf, P, N> dst_size? <Br/> strncat (replace_buf, replace_with, dst_size-strlen (replace_buf)-1); <br/> P = POS + strlen (Search ); <br/>}< br/> snprintf (DST, dst_size, "% S % s", replace_buf, P); <br/> free (replace_buf ); <br/>}< br/> return DST; <br/>}< br/>