2

文字列 6.78 を float に変換するにはどうすればよいですか? float 7.89 を文字列に変換するにはどうすればよいですか?

これらの質問は両方とも同様の答えを持っていますか?

4

3 に答える 3

3

<string>あなたが持っている標準ライブラリで

std::string std::to_string(float val)

and

float std::stof (const std::string&  str, size_t* idx = 0)

stofto_stringを参照

于 2013-06-13T22:17:08.100 に答える
0

あなたの環境は何ですか?

Visual Studio と Windows の場合は、atoi() と itoa() を使用します。

于 2013-06-13T22:30:31.873 に答える