And because I'm really sad, I wrote a slight generalisation: This'll do arbitrary characters from its argument. If you want a space, you'll have to tell the shell that strings all one argument like 'sfg jdq'. For weird characters, most consoles let you type Ctrl-Shift and then the hex value of the character - in the case of the original post, you need DC and B6 (U-umlaut and the paragraph sign in UTF-8, I think) #include <iostream> #include <list> int main(int argc, char** argv) { using std::cin; using std::cout; if(argc != 2) { cout << "Usage: chardrop '<chars>'\n" << " where <chars> is a string of characters you wish to ignore\n" << " from stdin.\n" << "e.g.\n" << " chardrop ^M (input ^M by Ctrl-V Ret on a console)\n"; return 1; } std::list<unsigned char> chars; unsigned char* pc = reinterpret_cast<unsigned char*>(*(argv+1)); while( *pc != '\0' ) chars.push_back( *pc++ ); unsigned char c; while(1) { c = cin.get(); if( cin.fail() ) break; if( std::find(chars.begin(),chars.end(),c) != chars.end() ) continue; cout.put(c); } return 0; }
Attachment:
signature.asc
Description: PGP signature