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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:07:01+00:00 2026-05-12T08:07:01+00:00

I’m supposed to write a library in c++ that should handle the connections to

  • 0

I’m supposed to write a library in c++ that should handle the connections to the kad network.
I’m trying to build a packet accordant to those used by aMule&co.

And I really can’t understand the difference between this code:

buffer = "\xe4\x20\x02";

and, for example, this code:

char p_buffer[36];
p_buffer[0] = 0xe4;
p_buffer[1] = 0x20;
p_buffer[2] = 0x02;

buffer = p_buffer;

(buffer is a private attribute of the class, while p_buffer is a local variable)

capturing the packets with wireshark gives me different results (the first one is right as I wanted, the second one not), like I was doing something wrong with little endian / big endian notations, I guess…

and why in the constructor of a class can’t I modify a [private] “char* buffer” like this:

buffer[0] = 0xe4;

? (it does not work, exits without any trace back error)

(if it can matter, I’m using crypto++ and boost libraries)

thanks in advance for any help_

  • 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-12T08:07:01+00:00Added an answer on May 12, 2026 at 8:07 am

    Your first code sample is roughly equivalent to:

    static const char buffer_internal[4] = { 0xe4, 0x20, 0x02, 0x00 };
    buffer = buffer_internal;
    

    The two differences here are:

    • The buffer is null-terminated
    • The buffer is unmodifiable. Attempting to modify it is likely to crash.

    Your second sample allocates a 36-byte modifiable buffer. However said buffer will also be discarded when it goes out of scope – be very careful here that it’s not used after being freed.

    As for the third sample, have you initialized ‘buffer’, if it is a pointer? You’ve not given enough information to really diagnose your error – the full class declaration and constructor would be helpful.

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

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
i want to parse a xhtml file and display in UITableView. what is the
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.