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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:23:34+00:00 2026-05-27T19:23:34+00:00

The following line of code writes unsigned int values into a file but the

  • 0

The following line of code writes unsigned int values into a file but the content of the file is not readable.

struct rabin_polynomial
{
    uint64_t start;
    uint16_t length;
    struct rabin_polynomial *next_polynomial;   
};

fprintf(out_file, "%llu,%u",poly->start,poly->length);

If I display the out put of the code instead to the command line screen it is readable.

the file “out_file” is not opened in binary mode.

Here part of the content of the output file:

 -ÍÍÍÍÍÍp\y";^æó r\ ÍÍÍÍ-       ÍÍÍÍÍÍ
Øâˆ¿»Iðr\ ÍÍÍÍ-      wÍÍÍÍÍÍ7OT-OØÚ‚\ ÍÍÍͤ*      L ÍÍÍÍÍÍî›ùçÉç`‚\ ÍÍÍÍð3       ÍÍÍÍÍÍ
Øâˆ¿»I°‚\ ÍÍÍÍðC       ÍÍÍÍÍÍíK¬è‹Ç{ ƒ\ ÍÍÍÍðS      •   ÍÍÍÍÍÍ-Ló3lJ–ÞPƒ\ ÍÍÍÍ…] 

And here is the expected out put:

0,2861 
2861,4096 
6957,3959 
10916,2380 
13296,4096 
17392,4096 
  • 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-27T19:23:35+00:00Added an answer on May 27, 2026 at 7:23 pm

    If you’re not getting the textual values you expect, it’s possibly down to the fact that you’re using incorrect format specifiers (I’m assuming you’ve populated the variables you’re trying to print here, though you may want to confirm this).

    %llu is explicitly for unsigned long long int which is not necessarily the same width as uint64_t.

    In C99, inttypes.h has macros for the format specifiers to be used for the exact-width and -at-least-as-wide-as data types.

    For example:

    uint64_t xyzzy = 42;
    printf ("Number is: %" PRIu64 "\n", xyzzy);
    

    In this case, PRIu64 means the printf format specifier, unsigned decimal output, for a 64-bit exact width variable. There are a wide variety of others for varying output types, plus equivalents for the scanf family as well (starting with SCN).

    Section 7.8.1 Macros for format specifiers of C99 lists them in detail.


    Based on your update where you’re not getting incorrect numbers but are rather getting what could only be described as rubbish, I would say your problems lie elsewhere. Even with corrupt pointers or data, I would not expect fprintf to generate non-numeric data for numeric format strings. It’s certainly possible since it’s undefined behaviour but very unlikely.

    You could get that sort of output for strings but that’s not the case here.

    In other words, I think you have to look elsewhere in your code for (as an example) memory corruption issues.

    One thing you could do to test if the problem lies in the line you think it does, is to change it to:

    printf("DEBUG: %llu,%u\n",poly->start,poly->length);
    fprintf(out_file, "%llu,%u",poly->start,poly->length);
    

    and see what comes out on the terminal.

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

Sidebar

Related Questions

i have the following class that writes to a file but is not working
Consider the following line of code: private void DoThis() { int i = 5;
I thought the following line of code should work fine: $(.1).attr('href', '#Home'); Right? But
I need to write the following line of code: ((eq item #\) (do-this...)) But
The following line of code generates the compile time error (PE19) There is no
I have the following line of code in a link on my webpage: <a
I have the following line of code: public bool dcpl_radar() { if (radar ==
I have the following line of code called very often: var configValue = System.Configuration.ConfigurationManager.AppSettings[ConfigValueKey];
I added following line of code in .vimrc let g:jslint_status = 'enabled' if exists(jslint_status)
I have the following line of code. <%= Html.Encode(string.Join(, , item.company1.companies.Select(x => x.company_name).ToArray())) %>

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.