Các bước tạo header file:
- Viết code, lưu thành
sub.h - Chương trình chính
subtraction.cinclude"sub.h"(dùng ngoặc kép) - Hai file cùng thư mục
sub.h
int sub(int m, int n) {
return m - n;
}
subtraction.c
#include <stdio.h>
#include "sub.h"
int main() {
int a=7, b=6, res;
res = sub(a, b);
printf("Hieu: %d", res);
return 0;
}
Kết quả
Hieu: 1