Home Backend Development C#.Net Tutorial What is the newline symbol in C language?

What is the newline symbol in C language?

Jan 04, 2023 pm 02:59 PM
c language

在c语言中,换行符是“\n”,其作用是另起一行,将当前位置移到下一行的开头;“\n”通常在输出中用作格式控制中,例如“printf("文本\n 文本\n");”。“\n”是一个转义字符,因为换行符不是一个可打印的字符,所以通过转义字符来表示。转义字符具有特定的含义,不同于字符原有的意义,故称“转义”字符。

What is the newline symbol in C language?

本教程操作环境:windows7系统、c99版本、Dell G3电脑。

C语言中换行符是'\n',作用是另起一行,将当前位置移到下一行的开头。

\n通常在输出中用作格式控制;

'\n'是一个转义字符,其意义是“回车换行”;因为换行符不是一个可打印的字符,所以通过转义字符来表示。

转义字符以反斜线"\"开头,后跟一个或几个字符。转义字符具有特定的含义,不同于字符原有的意义,故称“转义”字符。

一般放到printf()这类函数中使用,比如:

printf("this is a test\n Please check it\n");
Copy after login

输出:

What is the newline symbol in C language?

常用转义字符

What is the newline symbol in C language?

扩展知识

所有的ASCII码都可以用“\”加数字(一般是8进制数字)来表示。而C中定义了一些字母前加"\"来表示常见的那些不能显示的ASCII字符,如\0,\t,\n等,就称为转义字符,因为后面的字符,都不是它本来的ASCII字符意思了。

转义字符串(Escape String),即字符实体(Character Entity)分成三部分:第一部分是一个&符号,英文叫ampersand;第二部分是实体(Entity)名字或者是#加上实体(Entity)编号;第三部分是一个分号。

比如,要显示小于号(

用实体(Entity)名字的好处是比较好理解,一看lt,大概就猜出是less than的意思,但是其劣势在于并不是所有的浏览器都支持最新的Entity名字。而实体(Entity)编号,各种浏览器都能处理。

【相关推荐:C语言视频教程编程教学

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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Usage of typedef struct in c language Usage of typedef struct in c language May 09, 2024 am 10:15 AM

Usage of typedef struct in c language

The difference between strcpy and strcat in c language The difference between strcpy and strcat in c language May 08, 2024 pm 01:03 PM

The difference between strcpy and strcat in c language

What does real mean in c language What does real mean in c language May 09, 2024 pm 12:06 PM

What does real mean in c language

How to implement the power function in C language How to implement the power function in C language May 09, 2024 pm 11:33 PM

How to implement the power function in C language

What to do if there is an error in scanf in C language What to do if there is an error in scanf in C language May 09, 2024 am 11:39 AM

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

_complex usage in c language _complex usage in c language May 08, 2024 pm 01:27 PM

_complex usage in c language

How to use restrict in c language How to use restrict in c language May 08, 2024 pm 01:30 PM

How to use restrict in c language

_What does bool mean in c language? _What does bool mean in c language? May 08, 2024 pm 01:33 PM

_What does bool mean in c language?

See all articles