- 7
- 0
- 约7.88千字
- 约 9页
- 2020-09-10 发布于浙江
- 举报
#include stdio.h
#include string.h
#include stdlib.h
#define BUF_SIZE 4096
typedef struct
{
char *key;
int num;
char **trans;
}word_t;
void sys_err(const char *msg)
{
perror(msg);
exit(1);
}
int word_num(const char *filename)
{
FILE *fp;
char buf[BUF_SIZE];
int total = 0;
fp = fopen(filename, r);
if(fp == NULL)
sys_err(open file\n);
while((fgets(buf, BUF_SIZE, fp)) != NULL)
{
if(buf[0] == #)
total++;
}
fclose(fp);
return total;
}
int nword(const char *filename)
{
FILE *fp;
char buf[BUF_SIZE];
int total = 0;
fp = fopen(filename, r+);
if(fp == NULL)
sys_err(open fil
原创力文档

文档评论(0)