Search for a word in a file from code
-
Is there a way to search for a particular word in a file, no matter where it may be placed. I don't think opening the file and just using getline will work. Maybe there is a tool out there I can make use of in my code? Danny
bugDanny wrote: Is there a way to search for a particular word in a file, no matter where it may be placed. Sure. Open the file. Read the contents into a buffer. Search that buffer. Are you using C++, MFC, or just the Windows SDK?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-
bugDanny wrote: Is there a way to search for a particular word in a file, no matter where it may be placed. Sure. Open the file. Read the contents into a buffer. Search that buffer. Are you using C++, MFC, or just the Windows SDK?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
I'm using C++, but I could use MFC if needed. I suppose I was thinking of using getline to read the contents of the file word by word. You mean that I should read the whole file into a buffer, not just word by word. That would make it a lot easier to go back and forth in my search. I suppose I just didn't think of it that way. Danny
-
I'm using C++, but I could use MFC if needed. I suppose I was thinking of using getline to read the contents of the file word by word. You mean that I should read the whole file into a buffer, not just word by word. That would make it a lot easier to go back and forth in my search. I suppose I just didn't think of it that way. Danny
bugDanny wrote: You mean that I should read the whole file into a buffer, not just word by word. Correct.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb