#include <stdio.h>
#include <test2.h>
int g_i;
int func(int n){
g_i=1;
int sum = 0, i;
for (i=1; i<=n; i++){
sum+=i;
}
return sum;
}
int main(){
g_i=0;
int i;
long result = 0;
for (i=1; i<=100; i++){
result += i;
}
printf("result[1-100] =%d\n", result);
printf("result[1-250] =%d\n", func(250));
printf("result of func2(100) =%d\n", func2(100)); //call func2 in test2.c
}
#ifndef __TEST2_H_
#define __TEST2_H_
int func2();
#endif
#include "test2.h"
int func2(int n){
int i,sum;
for (i=1;i<n;i++){
sum+=i;
}
return sum;
}
test.o: test.c ./headfiles/test2.h
gcc -c -g test.c -I ./headfiles/ -o test.o
test2.o: test2.c ./headfiles/test2.h
gcc -c -g test2.c -I ./headfiles/ -o test2.o
test: test.o test2.o
gcc test.o test2.o -o test
clean:
rm -rf *.o
cleanall:
rm -rf *.o test
因篇幅问题不能全部显示,请点此查看更多更全内容