Convertir un float en string

hobbes Messages postés 23 Date d'inscription mercredi 12 février 2003 Statut Membre Dernière intervention 7 novembre 2003 - 10 avril 2003 à 13:57
cs_vieuxLion Messages postés 455 Date d'inscription samedi 26 octobre 2002 Statut Membre Dernière intervention 6 avril 2004 - 10 avril 2003 à 14:22
Bonjour,

Comment peut on convertire un float en string en c ????

Merci,

Hobbes
A voir également:

1 réponse

cs_vieuxLion Messages postés 455 Date d'inscription samedi 26 octobre 2002 Statut Membre Dernière intervention 6 avril 2004 8
10 avril 2003 à 14:22
alors celle là, on la voit souvent
ce serait pas mal de chercher sur ce site
exemple : float et string

sinon, utilise la fonction _fcvt
voici le copié/collé de l'example du msdn

/* FCVT.C: This program converts the constant
* 3.1415926535 to a string and sets the pointer
* *buffer to point to that string.
*/

#include <stdlib.h>
#include <stdio.h>

void main( void )
{
int decimal, sign;
char *buffer;
double source = 3.1415926535;

buffer = _fcvt( source, 7, &decimal, &sign );
printf( "source: %2.10f buffer: '%s' decimal: %d sign: %d\n",
source, buffer, decimal, sign );
}
0
Rejoignez-nous