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 X { int i; public: X() { i = 0; } void set(int
class a{ public void foo(int a){ System.out.println(super); } } class b extends a{ public
{ class Program { static void Main(string[] args) { int id = 0, stock
class LinkTest{ public: LinkTest(){ } void start(){ List list; Node * n ; for(int
class A2 { int numt=111; void hello() { System.out.println(Hello from A2); } } class
class A { public: A(); int get(); void set(); }; protected int A::var; seems
class Whatever { public: virtual ~Whatever(); protected: Whatever(); virtual void SomeMethod(); void OnEventOccurred(int x);
Class 1 private void checkDuplicateCustomer(BulkCustomerVO bulkCustomerVO) { PagedDuplicateCustomerVO duplicateCustomerVO = new PagedDuplicateCustomerVO(); duplicateCustomerVO.setCustomer(bulkCustomerVO.getCustomerVO()); duplicateCustomerVO
class A{ virtual int foo1(int a){ return foo1_1(a,filler(a)); } template<typename FunctionPtr_filler> int foo1_1(int a,
class Test { public static void main(String[] args) throws Exception { Test t =

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.