Zyziu Napisano Sierpień 4, 2018 Autor Zgłoś Napisano Sierpień 4, 2018 witam mam problemy z jedną z prostszych funkci winda, a dokładniej widowsową wersją dosowej funkcji. chodzi mianowicie o wsprintf. Piszę program obliczeniowy: float v; ... wsprintf(buf, "wynik = %f mag",v); SetWindowText /*tu co trzeba*/; otrzymuję: wynik = f mag dlaczego?? Pozdrawiam Cytuj
Nemo Napisano Sierpień 4, 2018 Zgłoś Napisano Sierpień 4, 2018 Spróbuj zamaist %f napisac %lf. Jesli to nei zadzialal to nie wiem w czym mzoe byc blad :| void Edit() { printf("Jednak nie działa. Kurde dołanczam sie do pytania :D"); } Cytuj
Aspect Napisano Sierpień 4, 2018 Zgłoś Napisano Sierpień 4, 2018 Z tego co piszą w MSDNie to funkcja wsprintf obsługuje tylko następujące formaty: c A single character. This sequence is interpreted as type WCHAR when the calling application uses the #define UNICODE compile flag and as type CHAR otherwise. C A single character. This sequence is interpreted as type CHAR when the calling application uses the #define UNICODE compile flag and as type WCHAR otherwise. d A signed decimal integer argument. This sequence is equivalent to the i sequence. hc, hC A single character. The wsprintf function ignores character arguments with a numeric value of zero. This sequence is always interpreted as type CHAR, even when the calling application uses the #define UNICODE compile flag. hd A signed short integer argument. hs, hS A string. This sequence is always interpreted as type LPSTR, even when the calling application uses the #define UNICODE compile flag. hu An unsigned short integer argument. i A signed decimal integer. This sequence is equivalent to the d sequence. lc, lC A single character. The wsprintf function ignores character arguments with a numeric value of zero. This sequence is always interpreted as type WCHAR, even when the calling application does not use the #define UNICODE compile flag. ld A long signed decimal integer. This sequence is equivalent to the li sequence. li A long signed decimal integer. This sequence is equivalent to the ld sequence. ls, lS A string. This sequence is always interpreted as type LPWSTR, even when the calling application does not use the #define UNICODE compile flag. This sequence is equivalent to the ws sequence. lu A long unsigned integer. lx, lX A long unsigned hexadecimal integer in lowercase or uppercase. s A string. This sequence is interpreted as type LPWSTR when the calling application uses the #define UNICODE compile flag and as type LPSTR otherwise. S A string. This sequence is interpreted as type LPSTR when the calling application uses the #define UNICODE compile flag and as type LPWSTR otherwise. u An unsigned integer argument. x, X An unsigned hexadecimal integer in lowercase or uppercase. Jak widać nie ma wśród nich odpowiedniego dla liczb zmienno przecinkowych (chociaż bardzo mnie to dziwi). Mozesz sprobowac zamiast wsprintf uzyc sprintf - z niąpowinno być wszystko w porządku. Cytuj
Oddity Napisano Sierpień 4, 2018 Zgłoś Napisano Sierpień 4, 2018 bool _ftoa (TCHAR *szStr, double d) { if (!szStr) return false ; gcvt (d, 15, szStr) ; if (szStr [lstrlen (szStr) - 1] == '.') szStr [lstrlen (szStr) - 1] = '\0' ; return true ; } float v ; TCHAR szV [32] ; _ftoa (szV, (double) v) ; wsprintf (buf, TEXT ("wynik = %s mag"), szV) ; Spróbuj w ten sposób. Pozdrawiam. Cytuj
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.