-
-, printf() scanf(). , , .
printf()
printf() :
printf( ,_1,_2,);
, , .
, %. printf() , %xxx .
_1,_2, , , . :
int a=2,b=5,c;
printf(a=%d,b=%d,=%d,c=%d\n,,b,a+b,9); //a=2,b=5,=7,=9
. , . , .
:
%[][][.][l|L]<>
%d %i int char;
%u unsigned int;
%o int char 8- ;
%x int char 16- ;
%f float ;
%e float ;
%g ;
%c int char ;
%s ;
% (&a).
l L.
long int %ld, %lo, %lu, %lx.
double c %lf, %le, %lg.
long double %Lf, %Le, %Lg.
, .
, . , , . :
Printf(%5s, ); //
Printf(%2d, 400); // 400
Printf(%10s,); // ððð
Printf(%7d, 400); // ðððð400
0n, n , , .
Printf(%07d, 400); // 0000400
*, ( ) .
Printf(%*d,5,10); // 5 , ððð10
|
|
, . , , .
Printf(%.0f,5.47); // 5
Printf(%8.2f,5.3334); // ðððð5.33
Printf(%10.5f,5.33); // ðð5.33000
printf(%.3e,55.3334); // 5.533e+01
*, ( ) .
Printf(%6.*f,2,7.1234); // 2, ðð7.12
*.*, , .
Printf(%*.*f,8,2,7.1234); // ðððð7.12
. .
Printf(%8.3s, ABCDEF); // ðððððABC
.
. .
Printf(%6dkm,30); // 30ððððkm
printf(%8.3sm, ABCDEF); // ABCðððððsm
+ , .. + . .
printf(%+d,300); // +300
printf(%+d,-300); // -300
.