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

  • Home
  • SEARCH
  • 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 4026332
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:57:25+00:00 2026-05-20T10:57:25+00:00

I am having following code. output of second %d in sprintf is always shown

  • 0

I am having following code. output of second %d in sprintf is always shown as zero. I think i am specifying wrong specifiers. Can any one help me in getting write string with right values. And this has to achieved in posix standard. Thanks for inputs

void main() {
    unsigned _int64 dbFileSize = 99;
    unsigned _int64 fileSize = 100;
    char buf[128];
    memset(buf, 0x00, 128);
    sprintf(buf, "\nOD DB File Size = %d bytes \t XML file size = %d bytes", fileSize, dbFileSize);
    printf("The string is %s ", buf);
    }

Output:

The string is
OD DB File Size = 100 bytes      XML file size = 0 bytes 
  • 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-20T10:57:25+00:00Added an answer on May 20, 2026 at 10:57 am

    I don’t know what POSIX has to say about this, but this is nicely handled by core C99:

    #include <stdio.h>
    #include <inttypes.h>
    
    int main(void) {
        uint64_t dbFileSize = 99;
        uint64_t fileSize = 100;
        char buf[128];
        memset(buf, 0x00, 128);
        sprintf( buf, "\nOD DB File Size = %" PRIu64 " bytes \t"
                      " XML file size = %" PRIu64 " bytes\n"
                      , fileSize, dbFileSize );
        printf( "The string is %s\n", buf );
    }
    

    If your compiler isn’t C99 compliant, get a different compiler. (Yes, I’m looking at you, Visual Studio.)

    PS: If you are worried about portability, don’t use %lld. That’s for long long, but there are no guarantees that long long actually is the same as _int64 (POSIX) or int64_t (C99).

    Edit: Mea culpa – I more or less brainlessly “search & replace”d the _int64 with int64_t without really looking at what I am doing. Thanks for the comments pointing out that it’s uint64_t, not unsigned int64_t. Corrected.

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

Sidebar

Related Questions

I'm having trouble figuring why the following code isn't producing the expected output. Instead,
I'm having some difficulty understanding why the output of the following code is not
I'm having an issue with the following code: private void DataPortal_Fetch(TaskCriteria criteria) { using
I'm having some problems with the following code: private class ClientPluginLoader : MarshalByRefObject {
I have the following code: SELECT <column>, count(*) FROM <table> GROUP BY <column> HAVING
Ok. I'm having an issue with the following bit of code: StreamReader arrComputer =
I have the following code written to make my lazy second CPU core working.
I'm having a weird problem, I have the following code in my page.php template
Imagine having the following scenario: You need to create a system where the Back
I'm having the following problem. I created a application context file for spring.net. The

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.