/* Addresses.c (c) Kari Laitinen http://www.naturalprogramming.com/ 2013-11-25 File created. 2013-11-25 Last modification. By running this program you can find you how memory is allocated for variables and arrays. */ #include int main() { int int_variable ; char char_variable ; int array_of_integers[ 4 ] ; char some_string[ 16 ] ; long long_variable ; double double_variable ; printf( "\n THE SIZES OF SOME DATA TYPES:\n" "\n char : %d bytes" "\n int : %d bytes" "\n long : %d bytes" "\n double : %d bytes", sizeof( char ), sizeof( int ), sizeof( long ), sizeof( double ) ) ; printf("\n\n DATA ITEM MEMORY ADDRESS\n" "\n \"int_variable\" %X" "\n \"char_variable\" %X" "\n \"array_of_integers[ 0 ]\" %X" "\n \"array_of_integers[ 1 ]\" %X" "\n \"array_of_integers[ 2 ]\" %X" "\n \"array_of_integers[ 3 ]\" %X" "\n \"some_string[ 0 ]\" %X" "\n \"some_string[ 1 ]\" %X" "\n \"some_string[ 2 ]\" %X" "\n \"some_string[ 15 ]\" %X" "\n \"long_variable\" %X" "\n \"double_variable\" %X\n", (long) &int_variable, (long) &char_variable, (long) &array_of_integers[ 0 ], (long) &array_of_integers[ 1 ], (long) &array_of_integers[ 2 ], (long) &array_of_integers[ 3 ], (long) &some_string[ 0 ], (long) &some_string[ 1 ], (long) &some_string[ 2 ], (long) &some_string[ 15 ], (long) &long_variable, (long) &double_variable ) ; } /* Here is a sample run of this program: THE SIZES OF SOME DATA TYPES: char : 1 bytes int : 4 bytes long : 4 bytes double : 8 bytes DATA ITEM MEMORY ADDRESS "int_variable" 22FF6C "char_variable" 22FF6B "array_of_integers[ 0 ]" 22FF50 "array_of_integers[ 1 ]" 22FF54 "array_of_integers[ 2 ]" 22FF58 "array_of_integers[ 3 ]" 22FF5C "some_string[ 0 ]" 22FF40 "some_string[ 1 ]" 22FF41 "some_string[ 2 ]" 22FF42 "some_string[ 15 ]" 22FF4F "long_variable" 22FF3C "double_variable" 22FF30 */