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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:11:36+00:00 2026-06-01T23:11:36+00:00

I have a file that can store up to 8 bytes of data. I

  • 0

I have a file that can store up to 8 bytes of data.

I have a system(let’s call is Sys1) which can bring me 8 bytes from the file and save it in a buffer inside the ram.

I can use these 8 bytes and copy some stuff in it, and then use this system to say “OK I’m done with it, just send these data back to the file”.

I want to bring the 8 bytes to the buffer, copy an integer to it, which takes 4 bytes, and on the remaining 4 bytes copy another integer. I just want two integers in 8 bytes, which I believe can be done.

I have managed to copy 4 bytes only, which is just 1 integer and managed to send it back to the file. So I have something like this:

     char *data;
     sys1.bring_the_8_bytes(&data);
    //now the 8 bytes are in the buffer,
    // data points to the first byte of the 8 byte  sequence
    int firstInteger = 10;
    int secondInteger = 20;
    //the two integers 
    memcpy(data,&firstInteger,sizeof(int));
    //now the values of the first integer have been copied successfully.
    sys1.send_the_8_bytes_back();

now this works fine! However I’m not sure how to copy the first integer and then the second immediately.

I should actually know the address of the first byte that is exactly after the last byte that is taken by the first integer, and then use this address as a destination address in the memcpy call, is my thinking correct? if yes,

how can I achieve this?? How can I find out this address that I want?

thanks in advance

  • 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-06-01T23:11:39+00:00Added an answer on June 1, 2026 at 11:11 pm

    The address you are having problems calculating is simply sizeof(int) bytes past the data pointer you already have. You can just cast the char* to an int* and work with that seeing as you know you always have a valid 8-byte region to write to.

    char *data;
    sys1.bring_the_8_bytes(&data);
    int *tmp = (int*)data;
    tmp[0] = 10;
    tmp[1] = 20;
    

    Or you can just add to the char* (add sizeof(int)) and do a second memcpy.

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

Sidebar

Related Questions

Assume that we have a large file which can be read in chunks of
I have xsd schema file which I can't change. Here is an excerpt that
I have an application which takes data from a file and stores it for
I have a file that can be any thing like ZIP, RAR, txt, CSV,
Can anyone give me any pointers. I have a text file that contains dates
I have custom component that I can place in my layout file (XML) for
I have a Mojolicious Lite script that gives out an executable file (user can
I have a loop that finds duplicate lines in a .ini file. I can
I have a Python application which sends 556 bytes of data across the network
I have a data file that stored like this : 6 byte (3*16-bits) header.

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.