From: André M. B. <and...@su...> - 2009-02-19 14:15:16
|
Dear users, I will need to develop an larg app and I´m interested to work with multiple modules. In these modules I want to define both functions and variables. Because of this I wrote a dummy example to check if it is all right. Please take a look at codes and answer me one question: if the codes are ok, when I need to use the extern qualifier? Best Regards André -->main.c #include <stdio.h> #include <stdlib.h> #include "sum.h" #include "dif.h" int main() { int a, b, c; printf("Enter a-->"); scanf("%d", &a); printf("Enter b-->"); scanf("%d", &b); sr = sum(a, b); dr = dif(a, b); printf("The sum is %d\n", sr); printf("The difference is %d\n", dr); system("PAUSE"); return 0; } -->sum.h int sr; int sum(int, int); -->dif.h int dr; int dif(int, int); -->sum.c int sum(int x, int y) { return(x + y); } -->dif.c int dif(int x, int y) { return(x - y); } |