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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:30:52+00:00 2026-05-26T14:30:52+00:00

I can’t find anything on the net that tells how to put a data

  • 0

I can’t find anything on the net that tells how to put a data type into a pre-allocated block of memory. I hate doing memory management myself, but in this case I must.

I have a block of memory that is 10 bytes long. (My app is 64bit using Visual C.) What I want to be able to do is put 1 unsigned int into bytes 0-3, a char into [4] and char into [5], and another unsigned int into [6-9].

I tried ssprintf already.

So I’m trying to figure out a way to 1) store it into this block of memory and 2) retrieve it.

  • 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-26T14:30:52+00:00Added an answer on May 26, 2026 at 2:30 pm

    IMO, a good way to accomplish that is by defining a struct containing the data you described:

    #pragma pack(1)
    struct complex {
        uint32_t a; // 4 bytes
        char b[2]; // 2 bytes (without paddding)
        uint32_t c; // 4 bytes
    };
    

    Then you can simply fill in your data:

    struct complex var;
    var.a = 10;
    var.b[0] = 'x';
    var.b[1] = 'y';
    var.c = 20;
    

    Note the #pragma pack(1) directive tells the compiler to use a 1-byte alignment. If you don’t know what it means, you can read about data structure alignment.

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

Sidebar

Related Questions

Can a LINQ enabled app run on a machine that only has the .NET
Can find why i get this error can someone help? package Android.data; public class
Can anybody help me? What should be the datatype for this type -07:00:00 of
Can I register a .Net COM class with the SingleUse -flag? The reason I
Can we change the color of the divider? Apple documentations says, that we can
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
can any one tell me why im only getting flag inserted into my tables
Can someone please help with the following: I am trying to force an asp.net
Can any one post the details to develop restful web service in .net from
Can somebody point me to a resource that explains how to go about having

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.