The article directories

    • 1. C Commonly used escape characters
    • 2. Application examples
    • Practice 3.

1. C Commonly used escape characters

  1. \t: a TAB stop for alignment
  2. \n: a newline
  3. \ \A:\
  4. \"A:"
  5. \ 'A:'
  6. \r: a carriage returnPrintf (" Zhang Wuji, Zhao Minzhou \ R Zhi Ruoxiao Zhao ");
  • instructions

2. Application examples

  1. \tThe 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. \nNewline 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. \rSaid the enterPrintf (" Zhang Wuji, Zhao Minzhou \ R Zhi Ruoxiao Zhao ");

  • Analysis: Output firstZhang Wuji zhao Minzhou, find a \r enter, will put the frontFour characters(Zhang mowgli zhaoThe 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 inzhang, directZhang mowgli zhaoTo 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