| | |
search word in file
![]() |
Not that I know of. You have to read some (all) of the file, then search using any of several possible methods.
If you expand on your problem definition, and show the work you've done to solve it, you will get better help here.
Please read the forum rules.
Val
If you expand on your problem definition, and show the work you've done to solve it, you will get better help here.
Please read the forum rules.
Val
"We Americans got so tired of being thought of as dumb by the rest of the world that we went to the polls last November and removed all doubt."
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
>I want to ask if there function in library of c++ to search word in file ??
No. You need to break it down into smaller operations like reading a file and searching a string for a word. Then you can do this:
Or this:
For example.
No. You need to break it down into smaller operations like reading a file and searching a string for a word. Then you can do this:
C++ Syntax (Toggle Plain Text)
std::ifstream in ( "myfile" ); if ( in ) { bool found = false; std::string search_for = "teapot"; std::string word; while ( in>> word ) { if ( word == search_word ) { found = true; break; } } //... }
C++ Syntax (Toggle Plain Text)
std::ifstream in ( "myfile" ); if ( in ) { bool found = false; std::string search_for = "teapot"; std::string line; while ( std::getline ( in, line ) ) { if ( word.find ( search_word ) != std::string::npos ) { found = true; break; } } //... }
I'm here to prove you wrong.
![]() |
Similar Threads
- Error trying to perform single word searches in address bar. (Viruses, Spyware and other Nasties)
- Find word in file!! (C++)
- Program for Grep search (Pascal and Delphi)
- print out the solve word puzzle (C++)
- Word Counter Help (Java)
- string: get token from string and compare token from text file (C++)
- Searching a file for a string (C++)
- How to detect when Word has closed (Visual Basic 4 / 5 / 6)
- need to find occurances in a string (C++)
- Word format for saving documents (Windows Software)
Other Threads in the C++ Forum
- Previous Thread: code Help* Please
- Next Thread: [Help] cos() function with Classes
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ char class classes code coding compaitibility compile console conversion count delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error factorial file floatingpoint forms fstream function functions game givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker loop looping loops map math matrix memory multiple net news node number numbertoword output parameter payment pointer problem program programming project projectassignmenthelp protection python random rank read recursion reference rpg skills string strings temperature template test text text-file tree url variable vector video win32 windows winsock word wordfrequency wxwidgets






