写一个.h文件
有这个问题[color=#FF6600][/color]里的那个程序wordpool.c,
如果我想写个wordpool.h
是不是这样写?
#define MAX_WORDS 200#define MAX_SIZE 10typedef struct _wordPool { int counter; char word[MAX_SIZE]; } WordPool;int findword(const char *wt);void add(const char *wp);void print() ;#ifndef _WORDPOOL_H#define _WORDPOOL_H#ifdef __cplusplusextern "C" {#endif#define MAX_WORDS 200#define MAX_SIZE 10typedef struct _wordPool { int counter; char word[MAX_SIZE]; } WordPool;int findword(const char *wt);void add(const char *wp);void print() ;#ifdef __cplusplus}#endif#endif /*_WORDPOOL_H*/
[解决办法]
楼主的写法是正确的
但最好在最前面加 #program once 避免被多个文件引用的时候 重复定义
[解决办法]
楼主的写法是正确的
但最好在最前面加 #program once 避免被多个文件引用的时候 重复定义
UP