如何在vc ++中搜索文件中的单词 [英] how to search for a word in a file in vc++
本文介绍了如何在vc ++中搜索文件中的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含一些内容的文本文件,我需要在文件中搜索一个单词,并且必须将找到我的搜索词的完整行写入另一个文本文件。
i使用ifstream打开文件但无法在文件中搜索文本。
I have a text file with some content i need to search the file for a word and have to write the complete line in which my search word is found to another text file.
i am using ifstream to open the file but unable to search the file for the text.
推荐答案
使用getline [ ^ ],然后使用 string :: find [ ^ ]进行搜索该行中的单词。
Read a line at time using getline[^], then use string::find[^] to search for the word in the line.
这篇关于如何在vc ++中搜索文件中的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文