您的位置:首页 > 其它

头文件中定义结构数组

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

原因:头文件中不能定义结构数组。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: