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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:45:36+00:00 2026-05-26T19:45:36+00:00

I have this buffer which I use for store some different types of data:

  • 0

I have this buffer which I use for store some different types of data:

int d;
char *current_Results;
char Results[1000];
current_Results = Results;

Now, I copy to this buffer the next data:

d = 50;
memcpy(current_Results, &d, sizeof(d));
printf("Current data is - %d\n", (int)(*current_Results));   // "Current data is - 50" Output OK!.

(current_Results)+= sizeof(d);

d = -20;
memcpy(current_Results, &d, sizeof(d));
printf("Current data is - %d\n", (int)(*current_Results));   // "Current data is - 1" Output WRONG!.
(current_Results)+= sizeof(d);
... and so on - wrong output later on...

What do I do wrong?

  • 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-26T19:45:37+00:00Added an answer on May 26, 2026 at 7:45 pm

    (int)(*current_Results) is not interpreting the bytes that are found at that location as an integer as you seem to expect. It is taking the one character found there and casts that to an int. You probably mean *(int*)current_Results.

    But all of what you are doing here may not be well defined because your are trying to access int* and arbitrary alignments. Don’t do that.

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

Sidebar

Related Questions

So.. I have a buffer with MP3 data (If I would save this buffer
I have an native C++ library which makes use of a large static buffer
I have a processing thread that I use to fill a data buffer. Elsewhere
Say I have a line in an emacs buffer that looks like this: foo
I'm using very large bitmaps and I store data in a big int[]. The
I have a SocketState object which I am using to wrap a buffer and
I have a circular, statically allocated buffer in C, which I'm using as a
I have a c# socket based server which serves TCP clients. I use telnet
If you have a pending operation, eg stream.BeginRead(_buffer, 0, _buffer.Length, _asyncCallbackRead, this); and you
I have this code in jQuery, that I want to reimplement with the prototype

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.