// ------------------------------ // First include all header files #include // ------------------------------ // Second, declare your global variables // Although it is better to avoid them int global1 = 1000; char global2[] = "Hello World!"; // ------------------------------ // Third declare your functions // Use prototypes if you need to use a function before declaring it void my_function1(char c); // This is a prototype void my_function2(int *i); // This is a prototype // ------------------------------ void my_function1(char c) { c = 'a'; printf("my_function1: c is %c\n", c); printf("my_function1: global1 %d, global2 %s\n", global1, global2); } void my_function2(int *i) { int regular_int = 1; static int static_int = 1; printf("regular_int: %d static_int: %d\n", regular_int, static_int); regular_int++; static_int++; *i = -2; printf("my_fuction2: i is %d\n", *i); printf("my_function2: global1 %d, global2 %s\n", global1, global2); } // The main function usually goes at the end int main() { char c = 's'; my_function1(c); printf("main: c is %c\n\n", c); int i = 3; printf("First invocation of my_function2\n"); my_function2(&i); printf("\nSecond invocation of my_function2\n"); my_function2(&i); printf("main: i is %d\n", i); return 0; }