The article directories
-
- 1. C Commonly used escape characters
- 2. Application examples
- Practice 3.
1. C Commonly used escape characters
\t
: a TAB stop for alignment\n
: a newline\ \
A:\
\"
A:"
\ '
A:'
\r
: a carriage returnPrintf (" Zhang Wuji, Zhao Minzhou \ R Zhi Ruoxiao Zhao ");
- instructions
2. Application examples
\t
The use of TAB stops
#include <stdio.h>
void main(a){
printf("Beijing \t Shanghai \t Guangzhou \t Shenzhen");
// let the console not exit
getchar();
}
Copy the code
2. \n
Newline use:
#include <stdio.h>
void main(a){
printf("Zhang SAN said: \n Hello!");
getchar();
}
Copy the code
3. \ \
: the first\
Is an escape character, second\
Is the output of the\
#include <stdio.h>
void main(a){
printf("Hello, \\world!");
getchar();
}
Copy the code
4. \r
Said the enterPrintf (" Zhang Wuji, Zhao Minzhou \ R Zhi Ruoxiao Zhao ");
- Analysis: Output first
Zhang Wuji zhao Minzhou
, find a \r enter, will put the frontFour characters
(Zhang mowgli zhao
The result of overwriting the first four characters of the \r carriage return because there are four characters behind it:Zhi Lou Xiao Zhao Min Zhou
. - The cursor finds the carriage return directly positioned in
zhang
, directZhang mowgli zhao
To replace the
#include <stdio.h>
void main(a){
printf("Cheung Moo-ji, Chiu Min-chow \ R Chi-Ryuk Siu Chiu");
getchar();
}
Copy the code
Practice 3.
- Requirements: Please use an output statement to achieve the output of the following graphics
#include <stdio.h>
void main(a){
printf("Name \t Age \ native place \t Address \njohn\ T12 \ hebei \t Beijing");
getchar();
}
Copy the code