useful c/c++ code (mostly string manipulation)