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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:00:31+00:00 2026-05-27T00:00:31+00:00

I have an input like char *input=00112233FFAA; uint8_t output[6]; What is the easiest way

  • 0

I have an input like

char *input="00112233FFAA";
uint8_t output[6];

What is the easiest way to convert input into output with sscanf? (prefer 1 line with no loop) The solution I have in mind doesn’t scale to 20+ hex string.

sscanf(input, "%x%x%x%x%x",output[0], output[1]....output[5]);
  • 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-27T00:00:31+00:00Added an answer on May 27, 2026 at 12:00 am

    Why scanf if this can be easily written by hand:

    const size_t numdigits = strlen(input) / 2;
    
    uint8_t * const output = malloc(numdigits);
    
    for (size_t i = 0; i != numdigits; ++i)
    {
      output[i] = 16 * toInt(input[2*i]) + toInt(intput[2*i+1]);
    }
    
    unsigned int toInt(char c)
    {
      if (c >= '0' && c <= '9') return      c - '0';
      if (c >= 'A' && c <= 'F') return 10 + c - 'A';
      if (c >= 'a' && c <= 'f') return 10 + c - 'a';
      return -1;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have designed an input validation loop in C#, and I would like it
As input I have a pointer to char pointer containing: {ab, cd} As output
I have an input like this RX Only : Gi1/0/15,Gi1/0/20,Gi1/0/17 I want to capture
I have some input like this: aaaaa bbb \n cccccc\n ddddd \neeee And I
i have a input like this $desc = &lt;p&gt;\r\n test job description!&lt;/p&gt; i have
If I have an input file like: US, P1, AgriZone, H, 1000, 1200, 1101,
I have a text input field like text box or text area. I want
I have a Login page that captures User input like this. MD5calc ss =
I have this use case of an xml file with input like Input: <abc
I have a NSURL member in my view controller. Based on user input like

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.