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 9021635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:18:08+00:00 2026-06-16T05:18:08+00:00

using c++ on windows, trying to set the locale to be used by the

  • 0

using c++ on windows,

trying to set the locale to be used by the swprintf function.

i need to include the thousand separator with the number which is printed out.

i tried several options…

_wsetlocale(LC_NUMERIC, L""); //default locale

also..

_wsetlocale(LC_NUMERIC, L"english");

and of course..

swprintf(buf, L"%d", 3546);

i also tried to display the number as follows

auto locale = _get_current_locale();
_swprintf_l(buf, L"%d", locale, 3546);

i need to get the thousands separator, i.e 3,456

i also placed a breakpoint to see the value of the locale variable, it contains the lconv struct with the thousands separator correctly set to , … however, swprintf is ignoring it.

  • 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-06-16T05:18:10+00:00Added an answer on June 16, 2026 at 5:18 am

    Tested on Linux

    Try with that :

    setlocale(LC_NUMERIC, "en_US.ISO8859-1");
    

    Example :

    #include <stdio.h>
    #include <time.h>
    #include <locale.h>
    
    int main(void)
    {
            setlocale(LC_NUMERIC, "en_US.iso88591");
            printf("%'d (%s)\n", 12345, setlocale(LC_NUMERIC, NULL));
            return 0;
    }
    

    You are missing the ' use %'d and not %d

    Still working with wchar

    #include <stdio.h>
    #include <time.h>
    #include <locale.h>
    #include <wchar.h>
    
    int main(void)
    {
            setlocale(LC_NUMERIC, "en_US.iso88591");
            wprintf(L"%'d\n", 12345);
            return 0;
    }
    

    An other example :

    #include <stdio.h>
    #include <time.h>
    #include <locale.h>
    #include <wchar.h>
    
    int main(void)
    {
            wchar_t buf[32];
            setlocale(LC_NUMERIC, "en_US.iso88591");
            swprintf(buf, 32, L"%'d", 12345);
            wprintf(L"%ls\n", buf);
            return 0;
    }
    

    Windows

    Well today I did test on Windows (with mingw) and this is not implemented…
    Please read this link, which provides a solution http://c-faq.com/stdio/commaprint.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set up an automated build system on Windows using Cygwin.
I'm trying to set up my local development environment, to which i'm using the
I am trying to set the PATH environment variable in windows 7 using a
I've been trying to set up a ftp server using IIS from windows 7.
i am trying to format a date using Windows GetDateFormat API function: nResult =
I am trying to draw a circle using Windows Form at runtime inside a
I'm trying to secure a WCF service using windows accounts. The service should run
I am trying to attach my mdf files to SQL server (using windows XP)
I'm trying to change the border style of my form using Windows Forms. The
I am trying to read some info from a text file by using windows

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.