Exemple d’utilisation de ‘sprintf’ pour stocker une chaîne formatée dans une ‘buffer’

Author:


Download


#include 

int main ()
{
  char buffer [128];
  int n;
  double x = 3.14, y = 678.9, z = -753.1, a = x * y + z;

  n = sprintf (buffer, "Le résultat des valeurs  %lf, %lf, et %lf, "
                       "est %lf.n",
                       x, y, z, a);

  printf ("Chaîne formatée: [%s]n taille:  %d caractères:n", buffer, n);

  return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *