22
Dec
Remove Characters within a String
Related Blog Items
- String Pattern Matching: Write a function that checks for a given pattern at the end of a given string
- Safe String Copy(strcpy) and Concatenate(strcat) Operations
- C++ Advanced Tutorial - Lesson 8
- String to Integer (atoi)
- Bad Standard APIs
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 - String Pattern Matching: Write a function that checks for a given pattern at the end of a given string
- Safe String Copy(strcpy) and Concatenate(strcat) Operations
- C++ Advanced Tutorial - Lesson 8
- String to Integer (atoi)
- Bad Standard APIs
Related Blog Items
- String Pattern Matching: Write a function that checks for a given pattern at the end of a given string
- Safe String Copy(strcpy) and Concatenate(strcat) Operations
- C++ Advanced Tutorial - Lesson 8
- String to Integer (atoi)
- Bad Standard APIs
No Comments
No comments yet.