Example Source Code:c/c++語言建立 #define,先建立 define_.h 檔。
#define INT_TEST 10
#define INT__ 123
#define BYTE unsigned char
#define True 1
#define False 0
char *str_include(void)
{
char *str="自製標頭檔...\n";
return str;
}
Example Source Code:將 define_.h 檔 #include 進來。
#include <stdio.h>
#include <stdlib.h>
/*
* 標頭檔
*/
#include "./define_.h"
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[])
{
char *receive=str_include();
printf("%s\n",receive);
printf("%s\n",str_include());
printf("%d\n",INT_TEST);
printf("%d\n",INT__);
printf("%d\n",True);
printf("%d\n",False);
printf("%d\n",sizeof(BYTE));
return 0;
}
Example Source Code:以上兩個檔案在 compiler 後會合併成一個。
#include <stdio.h>
#include <stdlib.h>
/*
* 標頭檔
*/
#include "./define_.h"
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define INT_TEST 10
#define INT__ 123
#define BYTE unsigned char
#define True 1
#define False 0
char *str_include(void)
{
char *str="自製標頭檔...\n";
return str;
}
int main(int argc, char *argv[])
{
char *receive=str_include();
printf("%s\n",receive);
printf("%s\n",str_include());
printf("%d\n",INT_TEST);
printf("%d\n",INT__);
printf("%d\n",True);
printf("%d\n",False);
printf("%d\n",sizeof(BYTE));
return 0;
}
//Answer:
//自製標頭檔...
//自製標頭檔...
//10
//123
//1
//0
//1
文章標籤
全站熱搜

留言功能已依作者設定調整顯示方式