Search

Sponsored Links

Meta

Categories

Archives

Recent Posts

RSS Feeds

22
Dec

Remove Characters within a String

Related Blog Items

The characters to be removed from a string is given as another string.

void remove(char src[], char del[])
{
     char hash[26] = {0};
     char *fsrc = del,*fdst;
     int count;
     while(*fsrc) {
          hash[*fsrc - ‘a’] = 1;
          fsrc++;
     }
     fsrc = fdst = src;
     while(*fsrc) {
          if ( (*fsrc == ‘ ‘) || ( hash[*fsrc - ‘a’] == 0 ) ) {
               *fdst = *fsrc;
               fdst++;
          }
          fsrc++;
     }
     *fdst = ”;
}

[tags] Remove Characters within a String, removing characters from string program, removing characters from string source code[/tags]

Popularity: 3%

You need to log on to convert this article into PDF


Related Blog Items

No Comments

No comments yet.

Leave a comment

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image