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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:01:08+00:00 2026-06-08T20:01:08+00:00

I got the following struct: struct Packet { short PacketSize; short Type; }; struct

  • 0

I got the following struct:

struct Packet
{
    short PacketSize;
    short Type;
};

struct SizeValidity
{
    short SizeEnc;
};

struct SendEncSecureCode
{
    Packet header;
    short EncSecurityToken;
    int lTime;
    SizeValidity ending;
};

And on my code i want to get the size of the struct with the sizeof operator like this:

SendEncSecureCode sendpacket;
sendpacket.header.PacketSize = sizeof SendEncSecureCode;

Problem is i always get size 0x10 instead of 0x0C i am specting, so i change the INT type to DWORD and still the same problem, later i try with DWORD32 and still the same, the compiler is setting it as 8 bytes. I am working on VC11 Beta and the soft is aim to x86 not x64. Thanks

  • 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-08T20:01:12+00:00Added an answer on June 8, 2026 at 8:01 pm

    To get the size you’re expecting, you can tell the compiler to use 1-byte packing:

    #pragma pack(push, 1)
    struct Packet
    {
        short PacketSize;
        short Type;
    };
    
    struct SizeValidity
    {
        short SizeEnc;
    };
    
    struct SendEncSecureCode
    {
        Packet header;
        short EncSecurityToken;
        int lTime;
        SizeValidity ending;
    };
    #pragma pack(pop)
    

    Please see http://vcfaq.mvps.org/lang/11.htm

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

Sidebar

Related Questions

I got a struct and an initializing function like following: struct someStruct { int*
I've got a following struct struct teststruct { int *a; void *data; }; Is
I have got an array of the following structs: typedef struct _my_data_ { unsigned
I've got the following structs in C++: (Using pragma pack 1) typedef struct _wfs_cdm_physicalcu
I've got the following structure: struct A { A(); virtual ~A(); virtual void Foo()
I'm a beginner to C++, I've got the following piece of code: struct Airline
The following code got me really puzzled. class class AVLTree { private: struct AVLNode
I have the following code: struct Node { int a; int b; }; Node
I have the following code. struct rectangle { int length; int breadth; }; int
Why I'm asking this is because following happens: Defined in header: typedef struct PID

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.