Created
September 21, 2012 22:37
-
-
Save robbkidd/3764326 to your computer and use it in GitHub Desktop.
Escaping things
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string> | |
#include <string.h> | |
int main() { | |
std::string str = "ab:cd:ef"; | |
const char *psz = str.c_str(); | |
for (;;) | |
{ | |
const char *pszNext = strpbrk(psz, ":"); | |
if (!pszNext) | |
{ | |
printf("%s", psz); | |
break; | |
} | |
printf("%.*s\\%c", pszNext - psz, psz, *pszNext); | |
psz = pszNext + 1; | |
} | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment