Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - By shaping the output.
By shaping the output.
int a = 0; printf("d% ",a); Shaping output 0.

char a =“0”; printf("c% ",a); Output 0 as characters.

char a[20]= " 0 123456789 "; printf("s% ",a); Output 0 123456789 as a string.

Defy a =1.0; printf("f% ",a); Output 1.000000 as a floating point.

int a = 10; printf("o% ",a); Octal plastic output 12.

int a = 10; printf("x% ",a); Hexadecimal shaping output a

int a =- 1; printf("u% ",a); Shaped output unsigned number 65536.

int a = 120; printf("e% ",a); Output 1.2e+02 by scientific notation.

int a = 120; printf("g% ",a); Use a shorter output width of %f or %e, instead of outputting meaningless 0, output 120.

In addition, the following additional symbols can be inserted between% and the above format characters.

L is used for long integers and is added before d, o, x and u.

-The output number or character is left in the field.

The minimum width of n (positive integer) data, indicating that the real number outputs n decimal places, and the character string intercepts the number of characters.

Such as: long int a = 0;; printf("ld% ",a); Long shaping output 0.