2010-03-20 5 views

Répondre

3
#include <sstream> 
... 
float f = 45.56; 
wstringstream wss; 
wss << f; 
// wss.str().c_str() returns LPCWSTR 
cout << wss.str() << endl; 
... 
+0

Ou en C via les variantes printf "w": http://msdn.microsoft.com/fr-fr/library/ms647550%28VS.85%29.aspx. Je préfère cependant cette méthode. –

1

L'API Win32 native n'a pas de fonctions pour l'impression des valeurs à virgule flottante, mais il y a une addition plus récente appelée strsafe qui a StringCchPrintf

TCHAR buffer[24]; 
StringCchPrintf(buffer, sizeof(buffer)/sizeof(TCHAR), "%f", float_value); 
+0

Merci pour votre commentaire, mais il semble compliqué et le simple ci-dessus fait le même travail :) – nXqd