ページ 11

printf

Posted: 2021年8月05日(木) 11:26
by しんくんパパ
Windows10よりAB4にて数字を文字に変換したいのですが、下記だと0.00になってしまします。
何が悪いのでしょう?

Declare Function sprintf CDECL Lib "crtdll" (lpString As *Byte,lpFormat As *Byte,...) As Long

Dim a As Double
Dim b[10] as Byte
a=12.34
sprintf(b,"%.2f",a)

Re: printf

Posted: 2021年8月05日(木) 15:57
by たかせ
少しバリエーション増やして実行した結果、
いずれも12.34と表示されました。
ちなみにPC環境はWindows10/20H2(X64)です。
また32ビットモードのみでコンパイル&実行しました。
ご確認願います。
よろしくお願いいたします。

Declare Function sprintf CDECL Lib "crtdll" (lpString As *Byte,lpFormat As *Byte,...) As Long

Dim a As Double
Dim b[10] as Byte
a = 12.34
sprintf(b,"%.2f",a)
MessageBox(NULL,b,"test",MB_OK)
sprintf(b,"%2.2f",a)
MessageBox(NULL,b,"test",MB_OK)
END

Re: printf

Posted: 2021年8月10日(火) 09:58
by ゲスト
AB4を入れ直したら改善しました。