1: /*********************************************************************
2: *
3: * Main Program
4: *
5: *********************************************************************
6: * FileName: main.c
7: * Dependencies: None
8: * Processor: Intel
9: * Compiler: Mingw
10: * Project: Global Variables
11: * Software: Dev-C++ 4.9.9.2
12: *
13: *
14: * Created By: Hussein Nosair
15: * Date: 03/30/2009
16: *
17: *********************************************************************
18: * File Description:
19: * This project will demoenstrate the use of global
20: variables and definitions
21: * Change History:
22: * Rev Date Description
23: * 1.0 03/30/09 Project Created
24: ********************************************************************/
25:
26: #include <stdio.h>
27: #include <stdlib.h>
28:
29: /****** NOTE ::
30: Must include the Global variabls header file in the main program
31: *******/
32: #include "GlobalVariables.h" // Include defined variables and functions
33:
34:
35: /************** Local Global Functions Definitions *************************
36: * The following is a local global functions to the main program. This means
37: * that any part of the code in main.c can call those 2 functions. However, this
38: * would not work with you if you try to call those 2 functions from GlobalVariables.c
39: * file or else where.
40: ****************************************************************************/
41: void func3(void); // Define Local function
42: void func4(void); // Define Local function
43:
44:
45: int main(int argc, char *argv[])
46: {
47: printf("i = %d \n", i); // Print out initial value of i
48: printf("n = %d \n", n); // Print out initial value of n
49:
50: i = 8; // Set a new value for i
51: printf("i = %d \n", i); // Print out the new value of i
52:
53: n = 4; // Set a new value for n
54: printf("n = %d \n", n); // Print out the new value of n
55:
56: func1(); // Call global function = function 1
57: func2(); // Call global function = function 2
58:
59: for(i=0; i<6; i++) // Print out global Array
60: printf("%d", Array[i]);
61:
62: // Print out blank lines
63: printf("\n");
64: printf("\n");
65:
66: func3(); // Call local function = function 3
67:
68: // Print out blank lines
69: printf("\n");
70: printf("\n");
71:
72: func4(); // Call local function = function 4
73:
74: system("PAUSE");
75: return 0;
76: }
77:
78: /****************** Local Global Functions Initialization *****************
79: * The following is initialization of the local global functions in main.c
80: * file. Please, note that you can not initialize the local global functions
81: * somewhere eles other than main.c file.
82: ***************************************************************************/
83: // Definition of local global function 3
84: void func3(void)
85: {
86: printf("This is ... Function 3 \n");
87: printf("Please, Enter a new value for variable i = ");
88: scanf("%d", &i);
89: printf("The new value for variable i = %d \n", i);
90: }
91:
92: // Definition of local global function 4
93: void func4(void)
94: {
95: printf("This is ... Function 4 \n");
96: for(i=0; i<6; i++)
97: {
98: printf("Please, Enter a new value for variable Array[%d] = ", i);
99: scanf("%d", &Array[i]);
100: }
101:
102: // Print out blank lines
103: printf("\n");
104: printf("\n");
105:
106: for(i=0; i<6; i++)
107: printf("a new value for variable Array[%d] = %d \n", i, Array[i]);
108: }