/* * ===================================================================== * Illustrate variable storage in C. * ===================================================================== * * Copyright (C) 1993-96 by Mark Austin and David Mazzoni. * * This software is provided "as is" without express or implied warranty. * Permission is granted to use this software on any computer system, * and to redistribute it freely, subject to the following restrictions: * * 1. The authors are not responsible for the consequences of use of * this software, even if they arise from defects in the software. * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. * 4. This notice is to remain intact. * * Written By : D. Mazzoni and M. Austin January 1994 * ===================================================================== */ #include int main( void ) { float fMiles; int iCount, iNum; double dDist, dTemp; /* [a] : Announce program */ printf( "STORAGE.C will illustrate how variables are stored in memory \n" ); printf( "------------------------------------------------------------ \n" ); /* [b] : Now list variables and their addresses. */ printf( "\"fMiles\" occupies %i bytes of storage that begins at location %x\n", sizeof( float ), &fMiles ); printf( "\"iCount\" occupies %i bytes of storage that begins at location %x\n", sizeof( int ), &iCount ); printf( "\"iNum\" occupies %i bytes of storage that begins at location %x\n", sizeof( int ), &iNum ); printf( "\"dDist\" occupies %i bytes of storage that begins at location %x\n", sizeof( double ), &dDist ); printf( "\"dTemp\" occupies %i bytes of storage that begins at location %x\n", sizeof( double ), &dTemp ); }