C language does not provide input and output statements. Input and Output operations are completed by C library functions. But it must contain the header file stdio. h.
Putchar () Outputs a character to the terminal
Printf () format characters:
① D is used to output a decimal integer.
% D output according to the actual length of Integer Data
% MD sets the output length to M. If the data length is smaller than m, the left space is filled. If the data length is greater than m, the actual output length is
% LD output long integer data
② The o Format operator outputs integers in octal form
③ X format operator outputs integers in hexadecimal format
④ U format character is used to output unsigned data, which is output in decimal format
⑤ The C format character is used to output a character
6 s format character to output a string
% S output actual length string
% Ms output string occupies m column. If the string length is smaller than m, left spaces are filled. If the string length is greater than m, the actual output is
%-MS output string occupies m column. If the string length is smaller than m, right fill space,
% M. Ns output occupies the m column, but only the n characters on the left of the string are taken and aligned on the right.
%-M. Ns M, N indicates the same as above, and is aligned to the left. If n> M, M automatically obtains n.
7. The F format operator outputs real numbers in decimal form
% F integer part all output, decimal part output 6 digits
% M. NF output data occupies a total of M columns, with N decimal places. If the value length is less than m, fill in spaces at left.
%-M. NF same as above, right fill space
Returns the real number in an exponential form.
% E the system specifies 6 decimal places and the 5-digit index (E + 002)
Returns the real number in the ⑨ g format. The F format or the eformat is automatically selected based on the value size.
3. Data Input
Getchar () input a character from the terminal
Scanf (format control, address list) Standard C scanf does not use % u. For unsigned data, enter % d, % O, or % x. * After % is used to skip the corresponding data. When inputting data, it cannot be specified that the precision, such as scanf ("% 7.2f", & A); is illegal.