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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:09:30+00:00 2026-06-02T12:09:30+00:00

I need to display some numbers with thousands grouping (in this case, using period

  • 0

I need to display some numbers with thousands grouping (in this case, using period as separator). So, I’m using the printf flag ' to achieve such thing.

With gcc everything goes well, but if I use icc, then I get this warning:

warning #269: invalid format string conversion

despite the fact that the number is indeed printed with the desired format.

For example, if we compile this simple program:

#include <stdio.h>
#include <stdlib.h>
#include <locale.h>

int main(int argc, char *argv[]) {
    setlocale(LC_NUMERIC, "da_DK");
    int i = 12345678;
    unsigned long int j = 987654321;

    printf("%d \t %'d \n%lu \t %'lu \n", i, i, j, j);
}

then we get this warning:

% icc -o simple simple.c 

simple.c(10): warning #269: invalid format string conversion
  printf("%d \t %'d \n%lu \t %'lu \n", i, i, j, j);
                                          ^

despite the fact that everything works as expected:

% ./simple 
12345678         12.345.678 
987654321        987.654.321 

So my questions are:

  1. How can this warning be suppressed?
  2. Is it safe to use ' as flag with printf and friends, with the icc compiler?

UPDATE:

I’ve just realized that an strange trick to suppress the 269 warning is defining a variable with the format, and pass that variable to printf:

#include <stdio.h>
#include <stdlib.h>
#include <locale.h>

int main(int argc, char *argv[]) {
    setlocale(LC_NUMERIC, "da_DK");
    int i = 12345678;
    unsigned long int j = 987654321;
    const char *strFormat = "%d \t %'d \n%lu \t %'lu \n";

    printf(strFormat, i, i, j, j);
}

UPDATE:

Because using apostrophe with printf is an XSI Extension (as stated by @Dave), in order to make the code more portable may be more useful to follow the recommendation from the C-FAQ, question 12.11 and use their implementation of commaprint.

  • 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-02T12:09:33+00:00Added an answer on June 2, 2026 at 12:09 pm

    To answer your second question, The compiler doesn’t actually control the processing of your format string; that’s your C library’s job. icc doesn’t recognize the format string because it is nonstandard, but as long as you understand that your code will only be valid on platforms whose c libraries support the ' flag, you’ll be ok.

    As the opengroup page shows, ' is an XSI extension, so your code will work on any XSI-conformant platform.

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

Sidebar

Related Questions

I need to display a NSNumberField that only accepts numbers. Is there some Cocoa-touch
I need to display some stats, numbers, and graphs about various game objects on
I'm using the Windows API GetNumberFormatEx to format some numbers for display with the
I am displaying a form with Symfony2 and Twig, and need to display some
Need some help assigning a mouseover event to display some icons that start out
At some point I need to display a disabled (greyed out by disabled=disabled attribute)
I need to display to the screen some values which are read in method
I have a RichTextBox and I add some texts programatically. I need to display
I display set of images(small). I need to show the larger image(300*300) at some
I need to display content from an OLAP cube in Sharepoint. This could be

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.