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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:13:26+00:00 2026-05-18T20:13:26+00:00

Here is the sample program and its output. typedef struct{ char name[30]; int empno;

  • 0

Here is the sample program and its output.

typedef struct{
    char name[30];
    int empno;
    int sal;
}empd, * empdPtr;

int main(){
    int x = 1;
    char y = 2;
    int z = 3;
    empd e;
    empdPtr ep = &e;

    printf("sizeof ep = %d e = %d \n",sizeof(ep),sizeof(e));
    printf("Address of e = %u, ep = %u x = %u y = %u z = %u\n",&e,&ep,&x,&y,&z);
    printf("Address of e.name = %u e.empno = %u e.sal = %u \n",&e.name,&e.empno,&e.sal);
    return 0;
}

$ ./a.exe
sizeof ep = 4 e = 40
Address of e = 2289536, ep = 2289532 x = 2289596 y = 2289595 z = 2289588
Address of e.name = 2289536 e.empno = 2289568 e.sal = 2289572

Here the difference between address of &e and &z is 52. But the sizeof(e) is 40. Why compiler added 12 more bytes even though 40 bytes is enough?

  • 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-18T20:13:27+00:00Added an answer on May 18, 2026 at 8:13 pm

    Compilers are at liberty to lay out memory as they see fit in the interests of better performance, for example, or whatever it is that is motivating the code generation. On an OS with very limited resources the compiler may elect to pack rather than align for access speed. Perhaps there are some implicit local variables being produced by the compiler. There are lots of possible reasons for this.

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

Sidebar

Related Questions

Here is the sample program and its output. typedef struct{ char name[30]; int empno;
Here is a sample from Kernighan & Ritchie's The C Programming Language: int getline(char
I need to execute a program and retrieve its stdout output in c++. I'd
Here is my sample code: from xml.dom.minidom import * def make_xml(): doc = Document()
Here is a sample code to retrieve data from a database using the yield
Here is the sample: Dim TestString As String = Hello, & Chr(0) & World
Here is my sample code. It is meant to be an iterative procedure for
here is some sample javascript: SomeObjectType = function() { } SomeObjectType.prototype = { field1:
This really has my stumped today. I'm sure its simple, but... Here is my
The program works in its current for but I would like to make it

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.