/* * ===================================================================== * Scope : Demonstrate Scope of Variables in a 1 file C Program. * * Copyright (C) 1994-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 : M. Austin and D. Mazzoni January 1994 * ===================================================================== */ #include enum {freezing = 32}; float fTemperature = freezing; /* Global float variable, which is visible throughout rest of this file, and also visible to other files */ int main( void ) { void TestFunction1(); void TestFunction2(); printf("In main() : fTemperature = %f\n", fTemperature); TestFunction1(); TestFunction2(); printf("In main() : fTemperature = %f\n", fTemperature); } /* * ----------------------- * Test functions 1 and 2 * ----------------------- */ int iValue1 = 5; void TestFunction1() { int iValue2 = 2; printf("In TestTunction1() : iValue1 = %d\n", iValue1); printf("In TestTunction1() : iValue2 = %d\n", iValue2); fTemperature += 32.0; } void TestFunction2() { int iValue1 = 2; printf("In TestTunction2() : iValue1 = %d\n", iValue1); }