标签:
<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>
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/fly_lhw/article/details/46957633