使用sprintf格式化负整数/双精度(Format negative integer/double using sprintf)
是否有可能只使用sprintf(c ++)格式化负整数/双精度,使得符号和值之间有空格?
from this: -1234 to this: - 1234编辑:它将进入一个char数组。
is it possible using only sprintf (c++) to format a negative integer/double in a way that there is a space between the sign and the value?
from this: -1234 to this: - 1234Edit: It will go in a char array.
最满意答案
我意识到这不是问题,但因为它被标记为C ++:
std::ostringstream out; out << std::internal << std::setw(6) << -1234; std::string result = out.str();I realize that this isn't the question but since this is tagged as C++:
std::ostringstream out; out << std::internal << std::setw(6) << -1234; std::string result = out.str();更多推荐
发布评论