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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:31:04+00:00 2026-05-13T16:31:04+00:00

anyone know a good way for doing this conversion? for example, take the char

  • 0

anyone know a good way for doing this conversion?

for example, take the char array holding ascii charcters “ABC”, the int conversion i’m looking for would change those characters to a single int with value 656667.

any help would be very much appreciated.

edit
really appreciate the replies. as someone noted i did say char array, and specifically this is a byte array, so there could be multiple ‘\0’ or NULL elements followed by additional ascii’s. using methods like strlen, etc will cause problems. thanks again for the current input.

  • 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-13T16:31:05+00:00Added an answer on May 13, 2026 at 4:31 pm

    Most of the time, one got to look at the actual problem.

    Parsing a packet protocol may or may not be easy, depending on the specification, but you can usually do better than throwing it all in a string…

    If you don’t know about them, look up Google Protocol Buffer, they can’t be used as is, but the idea is there.

    class UdpPacket
    {
    public:
      UdpPacket(const char str[], size_t length);
    
      uint16_t sourcePort() const { return mSourcePort; }
      unit16_t destinationPort() const { return mDestinationPort; }
      // ... The 3 other getters
    private:
      uint16_t mSourcePort;
      uint16_t mDestinationPort;
      uint16_t mLength;
      uint16_t mCheckSum;
      std::string mData;
    }; // class UdpPacket
    
    
    UdpPacket::UdpPacket(const char str[], size_t length):
      mSourcePort(0), mDestinationPort(0), mLength(0), mCheckSum(0),
      mData()
    {
      if (length < 8) throw IncompleteHeader(str, length);
    
      memcpy(mSourcePort, str, 2);
      memcpy(mDestinationPort, str, 2);
      memcpy(mLength, str, 2);
      memcpy(mCheckSum, str, 2);
      mData = std::string(str+8, length-8);
    } // UdpPacket::UdpPacket
    

    Net advantage ? You now have structured data. Of course there might be some endianness issue going on with the memcpy… you’ll have to check for it.

    Now, I don’t know what your mData is supposed to be, but of course it would be better if it was structured too.

    Using a simple int to store what does not look like an int at all, really is a bad idea I think… unless it was an int to begin with of course.

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

Sidebar

Ask A Question

Stats

  • Questions 341k
  • Answers 341k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your algorithm works by first creating references to two nodes… May 14, 2026 at 5:03 am
  • Editorial Team
    Editorial Team added an answer Finally, I found a solution, use IActivityWatcher and ActivityManagerNative, and… May 14, 2026 at 5:03 am
  • Editorial Team
    Editorial Team added an answer if those links are within a specific content, you can… May 14, 2026 at 5:03 am

Related Questions

I've got a medium scale project (a turn-based game) that's currently written in C/C++.
I am trying to comment an API (.Net) that I am exposing to a
I have a file wich has about 12 millon lines, each line looks like
I have and old(ish) C# method I wrote that takes a number and converts
does anyone know of a good way of doing the following, I need to

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.