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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:19:58+00:00 2026-06-13T09:19:58+00:00

This is driving me nuts because I don’t know the magic words to search

  • 0

This is driving me nuts because I don’t know the magic words to search for to find a solution.

I initialize:

unsigned char foo[] = {'0', 'x', '1', '1'};

unsigned char bar[] = {'\0'};

Essentially I want bar[0] to be equal to the value 0x11. How do I do that? I feel stupid and I’m pretty sure there’s a simple solution but I can’t figure it out. I tried

memcpy(&bar[0], &foo[0], 1);

But that just makes bar[0] have the value of 0x30, which is the ascii value of the ‘0’ character.

Any help/hints?

  • 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-06-13T09:19:59+00:00Added an answer on June 13, 2026 at 9:19 am

    In case you want to convert text values to integer, that can be done via sscanf function:

    char * string = "0x11";
    int numeric;
    sscanf(string, "%i", &numeric);
    // numeric is now 0x11
    

    Note that:

    • string actually has five characters, as there is a terminating zero at the end. If you ran C-string-expecting function on unterminated array {‘0’, ‘x’, ‘1’, ‘1’} you had above, if would continue processing data past the array, which is something you definitely do not want.
    • In real world use with externally-supplied data, you’d have to check for return value of sscanf to make sure it really did the conversion you wanted to do.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this has been driving me nuts because i know theres a simple solution but
I know jQuery pretty well. This one is driving me nuts because it's SO
Alright, this is driving me nuts because my regex is working on Rubular, but
This is driving me nuts. I think it is because of some connection string
This is driving me nuts because I'm being sent a form post that includes
This is driving me nuts. I can't seem to get the data template within
This is driving me nuts. I believe I asked this exact same question, but
This is driving me nuts. I've looked at all the relevant MSDN tutorials but
This is driving me nuts. I'm checking 3 conditions in my sql query. If
Ok, this is driving me nuts... I'm trying to rewrite my urls like this:

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.