Revision: 8831
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 10, 2008 01:19 by jaircazarin
Initial Code
#include<stdio.h> #include<stdlib.h> #include<string.h> char* deleteCharacters(char * str, char * charSet) { int hash [256]; if(NULL == charSet) return str; for(int i = 0; i < 256; i++) hash[i] = 0; for(int i = 0; i < strlen(charSet); i++) hash[charSet[i]] = 1; int currentIndex = 0; for(int i = 0; i < strlen(str); i++) { if(!hash[str[i]]) str[currentIndex++] = str[i]; } str[currentIndex] = '\0'; return str; } int main() { char s[2] = "a"; char s2[5] = "aca"; printf("%s", deleteCharacters(s2, s)); return 0; }
Initial URL
Initial Description
Given string a and b. Delete all characters of a that are in b.
Initial Title
Delete Characters.
Initial Tags
Initial Language
C