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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:35:33+00:00 2026-06-13T13:35:33+00:00

I have the following type definition: typedef union{ unsigned int Entry; struct { unsigned

  • 0

I have the following type definition:

typedef union{
unsigned int Entry;
struct {
    unsigned char EntryType;
    unsigned char EntryOffset[3];
};
} TLineDescriptor;

I also have the following use of the type:

TLineDescriptor LineDescriptor;
LineDescriptor.Entry = 40;
LineDescriptor.EntryType = 0x81;

sizeof(LineDescriptor) shows that this variable occupies 4 bytes of memory, which at first I assumed that it either held the int or the struct.

cout << LineDescriptor.Entry << " " << LineDescriptor.EntryType << endl;

However, the line above prints two different values, namely 129 ü, LineDescriptor.Entry is apparently referring to the memory location where the value 0x81 was saved. I’m not sure what happened with the 40.
But it is clear that my assumption was wrong. Can someone interpret and explain the type definition properly? Understanding it is crucial for me to working with the code I found.

Thank you 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-13T13:35:34+00:00Added an answer on June 13, 2026 at 1:35 pm

    These are not different values, actually. 129 is the character code for the character ü. The operator << of the ostream treats int and char data types differently, printing the numerical value for the first one and the character value for the latter one.

    So, your understanding of union types are correct. However, note that endianness could be an issue when dealing with union types. For example, on little-endian machines EntryType will hold the least significant byte of Entry and the EntryOffset array the others. But on big-endian machines, EntryType will hold the most significant byte.

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

Sidebar

Related Questions

I have C header file containing the following type definition: // example.h typedef struct
My structure definition is, typedef struct { int taxid; int geneid; char goid[20]; char
I have a C++ project with the following definition in the header file: typedef
We have a WSDL which contains the following type definition: ... <xsd:complexType name=OrderItem> <xsd:all>
I have a following definition. type TOmniTaskDelegate = reference to procedure(const task: IOmniTask); What
I have the following type being registered in Unity: container.RegisterType<IAzureTable<Account>, AzureTable<Account>>(); The definition and
I have following code: typedef int (*t_Function) (int x); t_Function Functions[MAX_FUNCTIONS]; int f(int x)
In ANTLR, I have a MismatchedTokenException with the following definition: type : IDENTIFIER ('<'
I have following type of data ntrt = paste (EL, 1:4, sep= ) repl
When using ASP.net webforms my usual solution would have following type of setup -

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.