[ create a new paste ] login | about

Link: http://codepad.org/GX4Jn1ws    [ raw code | output | fork ]

C++, pasted on Nov 22:
#include <iostream>
#include <cctype>

char* remove_words(char* s, char ch){
	char* t = s;
	for(char* p = s; *s; *s = *p){
		if(isalpha(*p)){
			if(*p == ch){
				++p;
				while(isalpha(*p))
					++p;
			} else {
				while(isalpha(*p))
					*s++ = *p++;
			}
			continue;
		}
		++s;
		++p;
	}
	return t;
}

int main(void){
	char s[] = "ada|apl|go|actor";

	std::cout << s << std::endl;
	std::cout << remove_words(s, 'a') << std::endl;
	return 0;
}


Output:
1
2
ada|apl|go|actor
||go|


Create a new paste based on this one


Comments: