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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:36:16+00:00 2026-05-18T21:36:16+00:00

class CHaraICICCC { int i; char c1; int j; char c2; char c3; char

  • 0
class CHaraICICCC
{
int i;
char c1;
int j;
char c2;
char c3;
char c4;
};

class CHaraIICCCC
{
int i;
int j;
char c1;
char c2;
char c3;
char c4;
};

void fun()
{
    CHaraICICCC eici;
    CHaraIICCCC eiicc;

    int icic = sizeof(eici); // -> output of icic is 16.
    int iicc = sizeof(eiicc); // -> output of icic is 12.
}

If any one knows, Please let me know why like this.
Thanks
Hara

  • 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-18T21:36:17+00:00Added an answer on May 18, 2026 at 9:36 pm

    Because of alignment. x86 compilers tend to align int types on 4 bytes boundary (for faster memory access) so CHaraICICCC would probably be laid out as this:

    byte  0: \
    byte  1: | <--- int i
    byte  2: |
    byte  3: /  
    byte  4: <----- char c1
    byte  5: \
    byte  6: | <--- Padding (wasted bytes)
    byte  7: / 
    byte  8: \
    byte  9: | <--- int j  
    byte 10: |
    byte 11: /
    byte 12: <----- char c2
    byte 13: <----- char c3
    byte 14: <----- char c4
    

    for a total of 15 bytes, while CHaraIICCCC would be:

    byte  0: \
    byte  1: | <--- int i
    byte  2: |
    byte  3: /  
    byte  4: \
    byte  5: | <--- int j 
    byte  6: |
    byte  7: /
    byte  8: <----- char c1
    byte  9: <----- char c2
    byte 10: <----- char c3
    byte 11: <----- char c4
    

    for a total of 12 bytes (with no bytes wasted for padding). Of course, this is much compiler-related and dependant on your compilation options.

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

Sidebar

Related Questions

{ class Program { static void Main(string[] args) { int id = 0, stock
class object { public: void check() { std::cout<<I am doing ok...<<std::endl; } }; int
class someclass {}; class base { int a; int *pint; someclass objsomeclass; someclass* psomeclass;
class Program { static void Main(string[] args) { Console.WriteLine(Fib 1: ); Console.ReadLine(); } long
class A { public override int GetHashCode() { return 1; } } class B
class A { public: A(const int n_); A(const A& that_); A& operator=(const A& that_);
class Foo { public: Foo() { do_something = &Foo::func_x; } int (Foo::*do_something)(int); // function
class Thread { public: Thread ( DWORD (WINAPI * pFun) (void* arg), void* pArg)
class Cache { int sizeOfCache;//no of RssFeedDocument private List<RssFeedDocument> listOfRssFeedDocument = null; } i
class A { public: int i; }; A *a = new A(); How to

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.