There are a lot of noobs here, so it's best to assume that I don't know anything in the answers.
I am writing a small application and it works well, but readability is a nightmare with my numbers.
Essentially, all I want to do is add commas to the numbers displayed on the screen to make it easier to read. Is there a quick and easy way to do this?
I use stringstream to capture my numbers (I'm not sure why this is even offered at the moment, it was just advised in the tutorial I worked with), for example (cutting out inappropriate bits):
#include <iostream> #include <string> #include <sstream> using namespace std; int items; string stringcheck; ... cout << "Enter how many items you have: "; getline (cin, stringcheck); stringstream(stringcheck) >> items; ... cout << "\nYou have " << items << " items.\n";
When this number is typed as something big, among everything else, it becomes quite a headache for reading.
Is there any quick and easy way to print "13 653 456" as opposed to "13653456", as it would be now (provided that, of course, it was introduced)?
Note. If that matters, I am making it a console application in Microsoft Visual C ++ 2008 Express Edition.
c ++
Dmatig
source share