C Tutorial/printf scanf/printf Type prefixes

Материал из C\C++ эксперт
Перейти к: навигация, поиск

Type prefixes: h

  1. Appear before type indicators d, i, o, u, x, and X.
  2. Display the value as short, for example, short integer (hd) and short unsigned integer (hu).


<source lang="cpp">#include <stdio.h> main() {

   int f = 9999;
   printf(" %hu \n",f);

}</source>

9999

Type prefixes: l (lower case l)

appear before type-identifiers d, i, o, u, x, and X.

display value as long, for example, long integer (ld) and long unsigned integer (lu).


<source lang="cpp">#include <stdio.h> main(){

   int f = 999999999;
   printf(" %lu \n",f);

}</source>

10000

Type prefixes: L (upper case L)

Available for type-identifiers e, E, f, g, and G.

Display value as long double.


<source lang="cpp">#include <stdio.h> main() {

   long double f = 9999.999;
   printf(" %LG \n",f);

}</source>

10000