Я хочу написать метод, который примет целое число и вернет std::string
этого целого числа, отформатированного запятыми.
Пример объявления:
std::string FormatWithCommas(long value);
Пример использования:
std::string result = FormatWithCommas(7800);
std::string result2 = FormatWithCommas(5100100);
std::string result3 = FormatWithCommas(201234567890);
// result = "7,800"
// result2 = "5,100,100"
// result3 = "201,234,567,890"
Что такое С++ способ форматирования числа как string
с запятыми?
(Бонус должен был бы обрабатывать double
.)