March 1st, 2012, 05:19 PM
searching for words in a file
i am new to visual c++ and i am learning oop ,i want ideas or how i can go about this small project i want to create i hope it will help me,i want to write a Class to search the file for a given pattern (eg, content) using visual c++
i want to put a button called search and i want to put an editbox1 where i can enter the path of the where the file is located eg "c:\\folder\\file1_.txt",then another editbox2 where i can enter words i want to search more like a the find button in word2007,i want it to work in such a way that when i enter the path where the file is located and click open the file should open and when i enter the word and click search it should show the string or word....i need ideas on how i can do this or how to do it your response will be highly appreciated
March 1st, 2012, 05:30 PM
Re: searching for words in a file
I would not concentrate on buttons, edit boxes, etc.
Originally Posted by quantumlaws
You should be concentrating on the logic -- given strings to find and a path to a file, return the matches. All the fancy GUI components mean nothing if you can't actually search a file for strings.
Assuming you're using MFC:
Assuming you're not using MFC:
void SearchInFile(const CString& strToSearch, const CString& fileToSearch)
It is the stuff in the middle of SearchInFile, regardless of what your GUI (or even if you have no GUI) that is important. There is no need for editboxes or buttons to write that code that's missing.
void SearchInFile(const std::string strToSearch, std::string& fileToSearch)
Once you have that coded, then and only then should you think about the interface.
Tags for this Thread
Click Here to Expand Forum to Full Width