头文件中定义结构数组
2014-03-26 11:37
211 查看
更新:原来整的依然有错误,原因是word_count.h的18行多了一个分号,真是手贱作死的节奏啊
头文件如下:
运行时出现如下错误
原因:头文件中不能定义结构数组。
头文件如下:
/************************************************************************* > File Name: word_count.h > Author: qinf > Mail: > Created Time: Mon 24 Mar 2014 08:03:49 PM CST ************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define IN 1 #define OUT 0 #define MAX_LINE (1<<15) #define LINE_LEN (1<<10) #define WORD_MAX 100000 #define WORD_SIZE 32; struct word_count { int ch_count; int word_count; int line_count; char *str_txt[MAX_LINE]; char *des_txt[MAX_LINE]; }; typedef struct word_count *p_count_struct; struct top_word { int cnt; char word[WORD_SIZE]; } topk_tab[WORD_MAX]; void init(p_count_struct *count_ent, struct top_word topk_tab[]); void wc_handler(char *filename, p_count_struct count_ent); void wc_choice(p_count_struct count_ent, char *command);
运行时出现如下错误
wc gcc -o main word_count.c word_count.h word_count_main.c In file included from word_count.c:8: word_count.h:33: error: expected ‘]’ before ‘;’ token word_count.h:34: warning: no semicolon at end of struct or union word_count.c:10: error: conflicting types for ‘init’ word_count.h:36: note: previous declaration of ‘init’ was here word_count.h:33: error: expected ‘]’ before ‘;’ token word_count.h:34: warning: no semicolon at end of struct or union In file included from word_count_main.c:8: word_count.h:33: error: expected ‘]’ before ‘;’ token word_count.h:34: warning: no semicolon at end of struct or union
原因:头文件中不能定义结构数组。
相关文章推荐
- MATLAB 定义结构体数组 并存到mat 文件 读取mat
- ServiceStack 项目实例 003 建议的文件结构定义及服务类说明
- Android中通过xml资源文件定义数组
- 如何分离出EF的三份结构定义文件
- TAO下IDL结构定义编译文件分析
- 如何使用opencv的c++接口来读取、写结构体数组到xml文件中
- 在C#中如何定义一个变长的结构数组?如果定义好了,如何获得当前数组的长度?
- 27、数据结构笔记之二十七数组的定义和概念
- 数据结构之数组16定义及实现
- 05.头文件中定义数组的问题解决办法
- 结构体数组定义和引用
- 平面文件根据XSD定义生成对应的XML结构文件
- iOS 结构体 定义变量注意事项以及保存到数组与读取
- 如何在C#中定义动态的数组结构啊??
- PE文件结构的一些相关定义
- 如何使用array资源文件中定义的资源数组
- Android -- 在xml文件中定义drawable数组
- centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课
- keil 工程头文件包涵及结构体重定义问题