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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:28:22+00:00 2026-05-11T12:28:22+00:00

Compiling on linux using gcc. I would like to convert this to hex. 10

  • 0

Compiling on linux using gcc.

I would like to convert this to hex. 10 which would be a. I have managed to do this will the code below.

unsigned int index = 10; char index_buff[5] = {0}; sprintf(index_buff, '0x%x', index); data_t.un32Index = port_buff; 

However, the problem is that I need to assign it to a structure and the element I need to assign to is an unsigned int type.

This works however:

data_t.un32index = 0xa; 

However, my sample code doesn’t work as it thinks I am trying to convert from an string to a unsigned int.

I have tried this, but this also failed

data_t.un32index = (unsigned int) *index_buff; 

Many thanks for any advice,

  • 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-11T12:28:23+00:00Added an answer on May 11, 2026 at 12:28 pm

    Huh? The decimal/hex doesn’t matter if you have the value in a variable. Just do

    data_t.un32index = index; 

    Decimal and hex are just notation when printing numbers so humans can read them.

    For a C (or C++, or Java, or any of a number of languages where these types are ‘primitives’ with semantics closely matching those of machine registers) integer variable, the value it holds can never be said to ‘be in hex’.

    The value is held in binary (in all typical modern electronic computers, which are digital and binary in nature) in the memory or register backing the variable, and you can then generate various string representations, which is when you need to pick a base to use.

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

Sidebar

Ask A Question

Stats

  • Questions 78k
  • Answers 78k
  • 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 Your question is about inheritance and interfaces. The following is… May 11, 2026 at 3:50 pm
  • added an answer Try these rules: RewriteCond %{HTTP_HOST} ^dev\. RewriteCond %{HTTP_HOST} !^dev\.askia\.com$ RewriteRule… May 11, 2026 at 3:50 pm
  • added an answer The reason there are gaps is due to rounding errors.… May 11, 2026 at 3:50 pm

Related Questions

I'm trying to find a definitive answer and can't, so I'm hoping someone might
In an application I maintain, we've encountered a problem with file descriptor limitations affecting
Are there any good language-agnostic distributed make systems for linux that are secure and
I'm doing my development work on my Windows machine, but my compiling on a

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.