Thursday, 29 May 2014

[MIT] Note 2 of Introduction to C and C++

18.01 Single Variable Calculus

Lecture 4 : Data Structures, Debugging



note: Structure Memory
ex.
#include <stdio.h>

int main()
{
    struct X
    {
        short s; 
        int i; 
        char c;
    };

    struct Y
    {
        int i;
        char c;
        short s;
    };

    struct Z
    {
        int   i;
        short s;
        char  c;
    };

    printf("%ld\n", sizeof(struct X));
    printf("%ld\n", sizeof(struct Y));
    printf("%ld\n", sizeof(struct Z));

    return 0;
}

12
8
8

Ref. http://ocw.mit.edu/courses/mathematics/18-01sc-single-variable-calculus-fall-2010/

No comments:

Post a Comment