我试图用C中的标准函数从文本文件中搜索某个单词 [英] I am trying to search for a certain word to be read from text file with standard function in C

查看:61
本文介绍了我试图用C中的标准函数从文本文件中搜索某个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用布尔值搜索单词从文本文件中出现的次数。



我尝试过的内容:



FILE * fpointer;

fPointer = fopen()

char [150];



while(!feof(fPointer)){

fgets(150,fPointer);



有问题使用fopen使用visual studio

search for the number of times a word appears from a text file, using Boolean.

What I have tried:

FILE * fpointer;
fPointer = fopen()
char[150];

while(!feof(fPointer)) {
fgets(150, fPointer);

had problem using fopen using visual studio

推荐答案

首先你必须把整个文件读成字符串,否则你可能会划分你的搜索字而找不到它。



查找单词 strtok 即可使用的功能。以下是解释文章
At first you must read the whole file into string else you may divide your search word and NOT find it.

For finding a word is strtok the usued function. Here is some explaining article.


这篇关于我试图用C中的标准函数从文本文件中搜索某个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆