What is the newline symbol in C language?
Jan 04, 2023 pm 02:59 PM在c语言中,换行符是“\n”,其作用是另起一行,将当前位置移到下一行的开头;“\n”通常在输出中用作格式控制中,例如“printf("文本\n 文本\n");”。“\n”是一个转义字符,因为换行符不是一个可打印的字符,所以通过转义字符来表示。转义字符具有特定的含义,不同于字符原有的意义,故称“转义”字符。
本教程操作环境:windows7系统、c99版本、Dell G3电脑。
C语言中换行符是'\n
',作用是另起一行,将当前位置移到下一行的开头。
\n
通常在输出中用作格式控制;
'\n
'是一个转义字符,其意义是“回车换行”;因为换行符不是一个可打印的字符,所以通过转义字符来表示。
转义字符以反斜线"\"开头,后跟一个或几个字符。转义字符具有特定的含义,不同于字符原有的意义,故称“转义”字符。
一般放到printf()这类函数中使用,比如:
printf("this is a test\n Please check it\n");
输出:
常用转义字符
扩展知识:
所有的ASCII码都可以用“\”加数字(一般是8进制数字)来表示。而C中定义了一些字母前加"\"来表示常见的那些不能显示的ASCII字符,如\0,\t,\n等,就称为转义字符,因为后面的字符,都不是它本来的ASCII字符意思了。
转义字符串(Escape String),即字符实体(Character Entity)分成三部分:第一部分是一个&符号,英文叫ampersand;第二部分是实体(Entity)名字或者是#加上实体(Entity)编号;第三部分是一个分号。
比如,要显示小于号(
用实体(Entity)名字的好处是比较好理解,一看lt,大概就猜出是less than的意思,但是其劣势在于并不是所有的浏览器都支持最新的Entity名字。而实体(Entity)编号,各种浏览器都能处理。
The above is the detailed content of What is the newline symbol in C language?. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Usage of typedef struct in c language

The difference between strcpy and strcat in c language

How to implement the power function in C language

What to do if there is an error in scanf in C language
