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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:34:42+00:00 2026-05-11T08:34:42+00:00

There was a bit of a surprise with some code today. I was compiling

  • 0

There was a bit of a surprise with some code today. I was compiling it on AIX, with the warning level set to anal to see what rogue issues might be lurking. Something new crawled out of the code.

 1540-2837 (W) '0' flag is disregarded when combined with                 precision and 'i' printf format. 

After looking at the offending line, I put together a little program to reproduce it. Testing it on several platforms showed that it is not AIX specific.

The first printf below mimics what was found in the program.

#include <stdio.h>     int main(void) {     int x = 3;      printf('Format 0.3i <%0.3i>\n', x);  // prints 003, and AIX does a warning     printf('Format  .3i <%.3i>\n', x);   // prints 003, with no warning     printf('Format   3i <%3i>\n', x);    // prints   3, with no warning.      return 0; } 

Normally, if leading zeros were needed, a format of ’03i’ would do the job nicely.

What does ‘%.3i’ really mean here?

Why does it have the behavior that it does?

  • 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. 2026-05-11T08:34:42+00:00Added an answer on May 11, 2026 at 8:34 am

    .X, where x is a number means ‘print at least X’ digits, so %.3i means print at least 3 digits. If the number is less than 100, it is left padded with zeros.

    From a doc on printf

    ‘For integer specifiers (d, i, o, u, x, X): precision specifies the minimum number of digits to be written. If the value to be written is shorter than this number, the result is padded with leading zeros. The value is not truncated even if the result is longer. A precision of 0 means that no character is written for the value 0.’

    There is another concept, ‘width’ (e.g. ‘%3i’) which causes a certain number of characters to be output (not necessarily digits, and the 0 specified is used to say that those characters should be 0s, as in ‘003’ and not spaces, as in ‘ 3’)

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

Sidebar

Ask A Question

Stats

  • Questions 61k
  • Answers 61k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Php has an inbuilt JSON Serialising function. json_encode json_encode Please… May 11, 2026 at 9:48 am
  • added an answer Check if scheduled task's security setting Scheduled task might be… May 11, 2026 at 9:48 am
  • added an answer I'd suggest you use an import table that gets updated… May 11, 2026 at 9:48 am

Related Questions

There was a post this morning asking about how many people disable JavaScript. Then
There was a registry fix for Visual Studio 2005 to prevent it from checking
There was a library of dynamic LINQ extensions methods released as a sample with
I was wondering if there was a .NET-compatible CLR that was implemented using the
I was wondering if there was a way to get at the raw HTTP
I was wondering if there was a good way to monitor a document library
I was wondering if there was a way to use find_by_sql within a named_scope.
I was wondering if there was a way to tell if an instance of
I was wondering if there was a way to determine if the last column
I was wondering if there was a simple way to use WMI to get

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.