How do I remove a character from a string?
If I have "abcdef" string and how do I remove
"b" ?
It is easy to remove the first character with this code:
#include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; #include & lt; String.h & gt; Int main () {char word [] = "abcdef"; Four words 2 [10]; Strcpy (WORD2, & amp; [1]); Printf ("% s \ n", word 2); Return 0; } and
strncpy (word 2, word, strollon (word) -1); will give me the string without the last character, but I still did not know how the middle string
Can control overlapping regions, I try to do something (not tested, maybe + -1 issue) Four words [] = "ABCDF"; Int idxToDel = 2; Memmove (& word [idxToDel], & amp; word [idxToDel + 1], strlen (word) - idxToDel);
Comments
Post a Comment