#include <stdio.h>#include<string.h> intMain () {CharC, s[ -]; intA=1234; floatf=3.141592653589; Doublex=0.12345678912345678; strcpy (s),"Hello,world"); C='\x41'; printf ("a=%d\n", a);//output in decimal integer format, display a=1234printf"a=%d%%\n", a);//output% number result a=1234%printf"a=%6d\n", a);//outputs a 6-bit decimal integer to the left of the fill space, showing a= 1234printf"a=%06d\n", a);//output 6-bit decimal integer left 0, display a=001234printf"a=%2d\n", a);//a more than 2 bits, according to the actual output a=1234printf"a=%-6d\n", a);///outputs a 6-bit decimal integer to the right with a blank, showing a=1234printf"f=%f\n", f);//The valid number of floating-point numbers is 7 bits, the result f=3.141593printf"f=6.4f\n", f);//Output 6 columns, 4 digits after the decimal point, result f=3.1416printf"x=%lf\n", x);//output long floating point x=0.123457printf"x=%18.16lf\n", x);//output 18 Columns, 16 digits after the decimal point, x=0.1234567891234567printf"c=%c\n", c);//Output character C=aprintf"c=%x\n", c);//ASCII code with hexadecimal output characters c=41printf"s[]=%s\n", s);//output Array string S[]=hello,worldprintf"s[]=%6.9s\n", s);//output A string of up to 9 characters S[]=hello,worreturn0; }
printf Format Output Summary