Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void escape(const char* s, char* t) {
- int i,j;
- i = -1;
- j = 0;
- while(s[++i]) {
- switch(s[i]) {
- case '\n':
- t[j++] = '\\'; t[j++] = 'n';
- break;
- case '\t':
- t[j++] = '\\'; t[j++] = 't';
- break;
- default:
- t[j++] = s[i];
- }
- }
- t[j] = '\0';
- }
- int
- main() {
- char t[100] = {0};
- escape("mohamed\t\n",t);
- printf ("t = %s\n", t);
- }
Advertisement
Add Comment
Please, Sign In to add comment