https://item.taobao.com/item.htm?
spm=686.1000925.0.0.9TTLHO&id=535006878999
<span style="font-size:18px;">#include <stdio.h>
#include <stdlib.h>
void escape(char *s, char *t);
int main(void)
{
char *s = malloc(30);
char *t = "what is your name?";
escape(s, t);
printf("%s\n", t);
printf("%s\n", s);
return 0;
}
void escape(char *s, char *t)
{
int i = 0,len = 0;
static int j = 0;
for (i = 0; *(t + i) != '\0'; i++)
{
switch (*(t + i))
{
case '\n':
*(s + (j++)) = '\\';
*(s + (j++)) = 'n';
break;
case '\t':
*(s + (j++)) = '\\';
*(s + (j++)) = 't';
break;
default:
*(s + (j++)) = *(t + i);
break;
}
}
*(s + (j)) = '\0';
}
</span>