C语言获取文件中单词并进行处理

该博客介绍了一个使用C语言实现的读取文件单词的函数process,它能通过回调函数processer处理读取到的单词。适用于进行hash函数测试,通过自定义isWord函数筛选特定字符组成的单词。
摘要由CSDN通过智能技术生成
/******************************************************
 *
 *         follows begin the word get process
 *
 ******************************************************/
bool isWord(char c)
{
        if ((('a' <= c) && (c <= 'z')) || (('A' <= c) && (c <= 'Z')) || ('-' == c)) {
                return true;
        }
 
        return false;
}
 
struct word_geter_engine {
        char * buffer;          /* contain the words */
        char * current;         /* where we reach in the buffer */
        char * end;             /* the last position + 1 */
        int bufferSize;         /* the capacity of the buffer */
        char wordBuf[WORDLEN];  /* store the word have got */
        bool needFill;          /* indicate whether need fill the buffer */
};
 
bool initStorer(int capacity, struct word_geter_engine * engine)
{
        engine->buffer = malloc(capacity
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值