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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:52:15+00:00 2026-05-11T18:52:15+00:00

I have an array of unsigned chars in c I am trying to print

  • 0

I have an array of unsigned chars in c I am trying to print in base 10, and I am stuck. I think this will be better explained in code, so, given:

unsigned char n[3];
char[0] = 1;
char[1] = 2;
char[2] = 3;

I would like to print 197121.

This is trivial with small base 256 arrays. One can simply 1 * 256 ^ 0 + 2 * 256 ^ 1 + 3 * 256 ^ 2.

However, if my array was 100 bytes large, then this quickly becomes a problem. There is no integral type in C that is 100 bytes large, which is why I’m storing numbers in unsigned char arrays to begin with.

How am I supposed to efficiently print this number out in base 10?

I am a bit lost.

  • 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-11T18:52:15+00:00Added an answer on May 11, 2026 at 6:52 pm

    There’s no easy way to do it using only the standard C library. You’ll either have to write the function yourself (not recommended), or use an external library such as GMP.

    For example, using GMP, you could do:

    unsigned char n[100];  // number to print
    
    mpz_t num;
    mpz_import(num, 100, -1, 1, 0, 0, n);  // convert byte array into GMP format
    mpz_out_str(stdout, 10, num);  // print num to stdout in base 10
    mpz_clear(num);  // free memory for num
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I have an array of unsigned chars, currently I'm trying to write a
I have an array as follows, unsigned char A[16] I am using this array
I have an array of four unsigned chars. I want to treat it like
I have an array of unsigned integers in C and a java array of
A cancer CT picture is stored inside a unsigned short array (1-dimensional). I have
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
Have an array of chars like char members[255]. How can I empty it completely
I'm trying to copy data into a unsigned char buffer within an array of
Im trying to increase the size of a **array with realloc which I have
I wanted to convert array< Byte>^ to unsigned char*. I have tried to explain

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.