Ich möchte eine Methode schreiben, die eine Ganzzahl verwendet und eine std::stringdieser mit Kommas formatierten Ganzzahlen zurückgibt.
Beispieldeklaration:
std::string FormatWithCommas(long value);
Anwendungsbeispiel:
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"
Wie formatiert C ++ eine Zahl als stringKomma?
(Bonus wäre, auch mit doubles umzugehen.)