Create a gist now

Instantly share code, notes, and snippets.

Escaping things
#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);
printf("%.*s\\%c", pszNext - psz, psz, *pszNext);
psz = pszNext + 1;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment