#include <stdio.h> float average (int a,int b); int main() { int num1, num2; float avrg;
printf("Please enter an integer: "); scanf("%d",&num1); printf("Please enter an integer: "); scanf("%d",&num2);
avrg = average(num1, num2);
printf("The average of %d and %d is %6.3f\n",num1,num2,avrg); return 0; } |
gcc -c main.c
float average(int n1, int n2) { float avg;
avg = (float)(n1+n2)/2; return avg; } |
gcc -c average.c
gcc -o main main.o average.o
분할 컴파일 하는 이유 : 컴파일 시간을 단축 시키기 수 있기 때문이다.
중복 인크루드 방지
#ifndef _AVERAGE_H //(if not define)
#define _AVERAGE_H
Float average(int a, int b);
#endif //_AVERAGE_H
'소프트웨어 > Linux' 카테고리의 다른 글
[MAC OSX] port 명령어 (0) | 2011.05.21 |
---|---|
USB util 컴파일하기 (0) | 2011.05.21 |
makefile (0) | 2011.05.11 |
Linux 디버깅 방법 (0) | 2011.05.02 |
Vi 편집기 (0) | 2011.04.26 |