programming with c language (6)

/* this example uses two files
 name them file1.c and file2.c
 use of the extern storage class between files
*/

/* filename: file1.c */
#include<stdio.h>

int sum=1;
extern f3(), f4();
main(){
 extern char ch;
 printf("%c\n",ch);
 f1();
 f2();
 f3();
 f4();
 return 0;
}

char ch='A';
f1(){
 printf("Function f1()\n");
 printf("%c\n",ch);
}

f2(){
 printf("Function f2()\n");
 printf("%c\n",ch);
}

/* filename: file2.c */

f3(){
 extern int sum;
 extern float cost;
 extern char ch;
 printf("Function f3()\n");
 printf("Sum = %d\n", sum);
 printf("cost = %f\n",cost);
 printf("ch = %c\n",ch);
}

float cost;
extern f2();
f4(){
 cost=5;
 printf("Function f4()\n");
 printf("cost = %f\n",cost);
 f2();
}

Click here to go back to 'C' programming
If you have comments or suggestions, email me at nicholas@tm.net.my

This page created with Netscape Navigator Gold (17/9/1999)