| | |
search word in file
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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 beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker list loop looping loops map math memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference rpg sorting string strings struct temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






