| | |
Search a txt file for words
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2006
Posts: 3
Reputation:
Solved Threads: 0
hi all , i have a txt file called myfile.txt , i want to open this file and search for the following
" this page is good/"
if i find this i want to read every thing after "/" until i reach <b> so for example
this page is good/so i want to copy this<b>
dont mind my question but i really dont know much in C++
thanks for your great help
" this page is good/"
if i find this i want to read every thing after "/" until i reach <b> so for example
this page is good/so i want to copy this<b>
dont mind my question but i really dont know much in C++
thanks for your great help
•
•
Join Date: Jul 2005
Posts: 1,681
Reputation:
Solved Threads: 264
We really don't like to write whole programs or routines for people. Here's a quick overview with a little more detail than p;rovided by Grunt. As you can tell, there are several choices you will have to make depending on what you know and don't know.
The phrase you are looking for is called a string. The file you are searching can be opened and read in as a sequence of strings or as a single string. You will then need to search for the string(s) from the file for the desired string. If found, the desired string is called a substring of the whole string. There are several ways to search for a substring depending on the type of string you use. You could use strstr() if you use C style strings, and I'm sure that the STL library will have functions to search for substrings as well, either in the string library itself or in the algorithm library. It would also be instructive to write your own function to familiarize yourself with the workings of strings. Last, but not least, if you aren't familiar with the concept of strings at all, then this project is beyond your scope of programming at this point and you should set your sights a little lower for now---like learning about strings, working with files, etc.
The phrase you are looking for is called a string. The file you are searching can be opened and read in as a sequence of strings or as a single string. You will then need to search for the string(s) from the file for the desired string. If found, the desired string is called a substring of the whole string. There are several ways to search for a substring depending on the type of string you use. You could use strstr() if you use C style strings, and I'm sure that the STL library will have functions to search for substrings as well, either in the string library itself or in the algorithm library. It would also be instructive to write your own function to familiarize yourself with the workings of strings. Last, but not least, if you aren't familiar with the concept of strings at all, then this project is beyond your scope of programming at this point and you should set your sights a little lower for now---like learning about strings, working with files, etc.
![]() |
Similar Threads
- How to search for a string in a file (C#)
- how to move to the second line in C++ .txt file reading? (C++)
- batch or wordlist search and replace in one file (Shell Scripting)
- getting words from .txt file (C++)
- uploading .txt file via phpmyadmin to Mysql (MySQL)
Other Threads in the C++ Forum
- Previous Thread: local variables
- Next Thread: C++ Refresher Question
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






