Is it possalbe to check all files

Alright so i already have a program that will take a person's name and age , along with their address and place it into a txt document every time its a new person, no i wanted to know that if i have 20 txt documents that each have a single name in it , can i write a program that will check all the txt documents until it finds a name that is entered by a user.

so basically if i enter 123 easy street the program will look in each txt file until it finds that address then display the information in that file
Something like that is definitely possible.
http://www.gnu.org/software/grep/manual/grep.html
Thank you and this looks very interesting and exactly what i am looking for but at the same time just to be sure it is compatible with c++ right ?
Enumerating the files on a system is mostly a function of the OS that you are running on. For instance Windows has you use the functions "FindFirstFile()" and then loop through the directory with "FindNextFile()" to fill in a structure with various tidbits of useful information about the files you find.

If you're looking for a cross-platform solution then there is always Boost::ASIO, but I personally don't have a lot of experience with that part of it so I can't say that I recommend it.

EDIT: keskiverto was linking you to an excellent tool that already does what you are looking for. Even if you don't end up using it, try to model your end product after the functionality found in grep.
Last edited on
Topic archived. No new replies allowed.