Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> การเขียนโปรแกรม C

Backslash Character Constants (Escape Sequences) ใน C

Backslash (\) นำหน้าตัวอักษร เพื่อแทน special characters (escape sequences)

ตาราง Escape Sequences

Characterความหมาย
\aAlert (beep)
\bBackspace
\fForm feed
\nNewline (บรรทัดใหม่)
\tHorizontal tab
\rCarriage return
\vVertical tab
\\Backslash \
\'Single quote '
\"Double quote "
\?Question mark ?

โปรแกรมตัวอย่าง

#include <stdio.h>
#define PI 3.14
float area;
void main() {
    double r = 1.0;
    area = PI * r * r;
    printf("Area is %f \n", area); // \n = newline
}

ผลลัพธ์

Area is 3.140000