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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:08:20+00:00 2026-05-30T05:08:20+00:00

I need a function that takes four unsigned char variables as parameters and combines

  • 0

I need a function that takes four unsigned char variables as parameters and combines them into an unsigned int. The first char variable being the first byte of the int, the second char being the second byte and so on. Here is what I have so far, it is not working properly and I can’t figure out why after messing around with it and googling for several hours.

uint32_t combineChar(unsigned char one, unsigned char two, unsigned char three, unsigned char four){

uint32_t com;

com = (uint32_t)one;

com = com << 8 | (uint32_t)two;

com = com << 8 | (uint32_t)three;

com = com << 8 | (uint32_t)four;

return com;       

}

  • 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-30T05:08:21+00:00Added an answer on May 30, 2026 at 5:08 am

    Your code is endianess-depend. The first byte (of uint32_t) is in some systems the leftest, and in some systems the rightest, so you may store the bytes in the opposite way than what to you want.

    (Actually, if you want just the uint32_t, it’s fine. Problems begin when you union it with char[4], or similar stuff)

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

Sidebar

Related Questions

I have a simple javascript function that takes two variables. I need to pass
I need to write a function that takes such a dictionary as the first
Need a function that takes a character as a parameter and returns true if
I need a C# function that takes 2 strings as an input and return
I need to write a function that takes 4 bytes as input, performs a
I have need for a function pointer that takes two arguments and returns a
If we need to implement a function that takes an array of integers and
Basically what I need to do is write a function that takes in a
I have a function that takes a string object name and I need the
I have Clojure function that takes a sequence of numbers chops it into the

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.