擷取1.PNG

在記事本用巨集編輯標頭檔(圖一)

擷取2.PNG

編輯完後存成.h(圖二)

擷取3.PNG

查看內容->位置(圖三)

開始編譯程式碼:

/*C語言 使用自訂的標頭檔area.h*/
#include<stdio.h>
#include<stdlib.h>
#include"C:\Users\ASUS\Desktop\area.h"
/*載入C:\Users\ASUS\Desktop\路徑下的area.h*/

int main(void)
{
    float base, height;

    printf("請輸入三角形的底:");
    scanf_s("%f", &base);
    printf("請輸入三角形的高:");
    scanf_s("%f", &height);
    printf("三角形的面積為:%f\n", TRIANGLE(base, height));

    system("pause");
    return 0;
}

結果為:

擷取.PNG

arrow
arrow
    創作者介紹
    創作者 愛學習 的頭像
    愛學習

    愛學習

    愛學習 發表在 痞客邦 留言(0) 人氣()