如何用逗号写数字?
有时在 C++ 中我想使用像 1000000 这样的大数字,这很令人困惑。我如何使用逗号(如果可能的话)?
例如我希望这个工作
int x = 1,000,000;
回答
您可以使用自 c++14 以来的数字分隔符
int x = 1'000'000
这对你有用吗?
- @ariel • `int x=1'0;` is not using them wrong. They are intended to be a separator for readability. Cosmetic, like a comment. That's an unusual grouping, but isn't wrong.