Thread: sizeof struct

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    27

    sizeof struct

    I'm running the following prog :

    Code:
    #include <stdio.h>
    
    
    struct customer {
          short number;      //   1:
          int postcode;       //   2:
    };
    
    int main() {
        printf("%d\n",sizeof(customer));
    }
    If I run it with line 1 in comments the output is 4.OK for that.
    If I run it with line 2 in comments the output is 2.OK for that too.
    But if i run as it is above the outout is 8.Why is that?

    Thank you in advance.
    Last edited by k_w_s_t_a_s; 05-10-2003 at 02:19 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 06:55 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. Replies: 10
    Last Post: 05-18-2006, 11:23 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 5
    Last Post: 01-09-2004, 06:58 PM