Normalize whitespace with strtok in C -


After trying to remove strings, I am trying to use strtok to normalize whitespace in the string after removing a substring . Occasionally when I remove a substring, then there will be 2 spaces between two words and I want to subtract it from 1, for example "increase and fall" of the word "rise and fall of Rome" by 2 Between and fall

It has so far to me, but I have no experience with the stroke:

  char * strdel (char * string, const char * substring) {int mainlen , Sublen; // gets the first occurrence of the sub-string * del_sub = strstr (string, substring); Char * wspc, * df; While (del_sub! = NULL) {// The length of the string is found from the beginning of the substrings / mainlen = strlen (del_sub) found in the main string; // finds the length of the substrings sublen = strlen (substring); // Removes the number of required bytes after the first instance of sub-base (del_sub, del_sub + sublen, strlen (del_sub)); Wspc = strtok (string, ""); While ((df = strtok (NULL, "") = = null) {strcat (string, df); Memset (DF, 0, Strangel (DF)); } // // The second version of the substring continues to search until it is equal to del_sub = strstr (string, substrings); } Return (string); }  


Comments