C语言转义字符

 

\b退格 

#include <stdio.h>

int main()
{
    char c1='\b';  //退格符 
    printf("abcd\n");
    printf("ab%ccd",c1);  //显式acd,b被退格删除了 
    
    return 0;
}

 

 

\t制表符
#include <stdio.h>

int main()
{
    char c1='\t';  //到下一个制表符的位置 
    
    printf("12%cxy\n",c1);  
    printf("123%cxy\n",c1);
    printf("1234%cxy\n",c1);
    printf("123456%cxy\n",c1);
    printf("1234567%cxy\n",c1);
    printf("12345678%cxy\n",c1);  //从这行的显示可以看出,制表符默认8个字符位置 
    printf("123456789%cxy\n",c1);
    
    return 0;
}

 

\r回车:到本行的头 

#include <stdio.h>

int main()
{
    char c1='\r';  //回车:到本行头的位置 
    
    
    printf("12345678%cxy",c1);  
    
    
    return 0;
}

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2025-03-25 07:50  天子骄龙  阅读(19)  评论(0)    收藏  举报