Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 202023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:15:03+00:00 2026-05-11T17:15:03+00:00

Very much a noob here, so it’s best to assume I know nothing in

  • 0

Very much a noob here, so it’s best to assume I know nothing in any answers.

I’ve been writing a little app, and it’s working well, but readability is a nightmare with my numbers.

Essentially, all I want to do is to add commas into the numbers displayed on the screen to make it easier to read. Is there a quick and easy way to do this?

I’ve been using stringstream to grab my numbers (I’m not sure why this is even suggested at this point, it was simply advised in the tutorial I worked through), such as(cropping out the irrelevent 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 that number is typed as something large, amongst everything else it becomes quite a headache to read.

Is there any quick and easy way to make it print “13,653,456” as opposed to “13653456” like it would right now (assuming that’s what was input of course)?

Note: If it matters, I’m making this as a console application in Microsoft Visual C++ 2008 Express Edition.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:15:03+00:00Added an answer on May 11, 2026 at 5:15 pm

    Try the numpunct facet and overload the do_thousands_sep function. There is an example. I also hacked up something that just solves your problem:

    #include <locale>
    #include <iostream>
    
    class my_numpunct: public std::numpunct<char> {
        std::string do_grouping() const { return "\3"; }
    }; 
    
    int main() {
        std::locale nl(std::locale(), new my_numpunct); 
        std::cout.imbue(nl);
        std::cout << 1000000 << "\n"; // does not use thousands' separators
        std::cout.imbue(std::locale());
        std::cout << 1000000 << "\n"; // uses thousands' separators
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My apologies as I'm very much a Java noob. Anyways, I think I've dumbed
Would very much appreciate any help or hint on were to go next. I'm
I get very much confused when it comes to pointers. I want to know
I'm very much new to programming and have been doing fairly well so far.
I have to start by saying that I am very much a programming noob.
Very much a newbie question here but I cannot find a clear answer on
I'd be very much interested hearing any tips on how a simple algorithm can
I'm a jQuery noob here, please help! Much much appreciated! my urls.py: url('^xhr_test/$','posts.views.xhr_test'), my
I'm still very much a noob, having a lot of fun learning the basics
I'm very much a noob/hobbyist programmer, putting together a few simple Mac apps. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.