“spécificateurs de format printf” Réponses codées

format de type printf

%d--> for int

%u--> for unsigned int

%ld--> for long int or long

%lu--> for unsigned long int or long unsigned int or unsigned long

%lld--> for long long int or long long

%llu--> for unsigned long long int or unsigned long long
M3as

spécificateurs de format printf

#include <stdio.h>

int main(){
   printf ("Characters: %c %c \n", 'a', 65);
   printf ("Decimals: %d %ld\n", 1977, 650000L);
   printf ("Preceding with blanks: %10d \n", 1977);
   printf ("Preceding with zeros: %010d \n", 1977);
   printf ("Some different radices: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100);
   printf ("floats: %4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416);
   printf ("Width trick: %*d \n", 5, 10);
   printf ("%s \n", "A string");
   return 0;
}

output: 
  Characters: a A
  Decimals: 1977 650000
  Preceding with blanks:       1977
  Preceding with zeros: 0000001977
  Some different radices: 100 64 144 0x64 0144
  floats: 3.14 +3e+000 3.141600E+000
  Width trick:    10
  A string
Maou Shimazu

spécificateurs de format printf

d decimal
c character
s string
f float
e scientific notation
x hexadecimal

\n new line
\t horizontal tab
\\ backslash
\b backspace
\' single quote
\" double quote
Maou Shimazu

Réponses similaires à “spécificateurs de format printf”

Questions similaires à “spécificateurs de format printf”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code