/* * ====================================================================== * File1 : Demonstrate scope of variables and functions in a two * file C program. * * Copyright (C) 1998 by Mark Austin and David Chancogne. * * 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 : Mark Austin * ====================================================================== */ #include /* Declarations for (external) functions */ void testFunction1(); void testFunction2(); /* Declarations for global and file-level variables */ enum {freezing = 32}; float fTemperature = freezing; /* Global float variable, which is visible throughout rest of this file, and also visible to other files. */ static int iValue1 = 10; /* Scope of iValue1 restricted to this file, */ int main( void ) { int iCount; /* [a] : Increment variables in external file. */ printf("In main() : iValue1 = %d\n", iValue1 ); printf("In main() : fTemperature = %f\n", fTemperature); testFunction1(); printf("In main() : fTemperature = %f\n", fTemperature); /* [b] : Call testFunction2() three times. */ for(iCount = 1; iCount <= 3; iCount++ ) testFunction2(); printf("In main() : Finished calling testFunction2() three times\n"); printf("In main() : fTemperature = %f\n", fTemperature); } void testFunction1() { printf("In testFunction1() located in file 1 : Value1 = %d\n", iValue1); }