Reputation: 2 Apprentice
- Active Posts:
- 67 (0.02 per day)
- 26-December 05
- Profile Views:
- Last Active:
- Apr 24 2013 09:40 PM
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Favorite Gaming Platform:
- Your Car:
- Who Cares
- Dream Kudos:
Posts I've Made
Posted 21 Apr 2013why dont you just compare each word with the different categories you intend to have.To my understanding, the labels variable holds the current word.Make your comparison against that
Posted 21 Apr 2013@David, first of all you should not use cin to read from a file, unless you absolutely need to.Consider using a function like getline().Secondly, i dont see anywhere in your program where you are actually tellin your program to open a specific file, what is your file char variable initialised to in regards to filename.if im correct, then your program is not opening anything.Always make sure you check your File input output operations for errors to make your debugging life easier
Posted 21 Apr 2013well done skydiver.This is why it is good to allow new eyesto take a look at yourcode , even thouh i found a temporary solution which i just hacked away.I will like to tell you that i have fixed it based on your correction and all is well now.I am able to provide a reliable service over UDP.Thank you once more
Posted 16 May 2012@quizton,at first i mentoned that the method of readAllLines above was inefficieng actually it is not that bad after running some tests.I recommend you still use that method to read all the lines into the array, then call your searchFile method like this.
Note. you are no longer passing the file name in the function but rather the lines array.Remember, this lines array was gotten by calling the readAllLines method on the file.
The implementation of your searchFile function should ofcourse be modified a little as noted below.
1) remove the line that reads from the file using the StreamReader class.You no longer need it as you have previously read the file.
2) you need to surround your regular expression statements in a while loop that will go through the lines array and append evey match it finds on a line to the richtextbox.for example, To search on line, you call the regex isMatch method like this
3)keep a bool variable so that after the loop finishes execution you can decipher whether atleast a match has been found or not, in order to show appropriate message.
Posted 15 May 2012Your problem can be solved in many ways, but i choose to talk about two solutions in which one has already been mentioned above.
The first solution i will suggest is, if memory is not an issue, then you can use the ReadAllLines method from the File class to read all the contents of the file into an array.
string lines = System.IO.File.ReadAllLines(@"location of file");
You can then search for substrings on each line to find your search term.Using this approach will enable you to find the line number and closest matches but it is a lazy and inefficient.
- Member Title:
- D.I.C Head
- Age Unknown
- Birthday Unknown
- Years Programming:
- Programming Languages:
bluesuus hasn't added any friends yet.