以下是引用勇者锋狂在2009-10-8 16:15:50的发言:
那请问,如果需要循环输入,该如何改动呢?还有,是不是预处理命令多了,程序执行的速度就慢了呀??
Give you an example for include, and you will understand what the include does during compiling.
/* define some enum in header1.h */
/*
Name: header1.h
Copyright:
Author:
Date: 08-10-09 16:43
Description:
*/
MY_ENUM1,
MY_ENUM2,
MY_ENUM3,
MY_ENUM4,
/* define enum in header2.h */
/*
Name: header2.h
Copyright:
Author:
Date: 08-10-09 16:44
Description:
*/
typedef enum
{
#include "header1.h"
MY_ENUM5
}myenum;
/* use this enum in main.c */
/*
Name: main.c
Copyright:
Author:
Date: 08-10-09 16:45
Description:
*/
#include <stdio.h>
#include <stdlib.h>
#include "header2.h"
int main(int argc, char *argv[])
{
myenum my = MY_ENUM1;
printf("%d",my);
system("PAUSE");
return 0;
}
you can test it.