+ 2

How can we find a word from text using loop

cpp

25th Mar 2017, 11:17 AM
abdul rafay
abdul rafay - avatar
2 Answers
+ 9
If the text is all one string, then go through each character of the string. Have an if statement that checks for matching characters in the string. If one is found, advance one character in both the search word and the string of text. Interesting question; this is also used for searching pi for patterns and digits. If you want more info, respond back or search for "searching for digits of pi" or something like that. I bet hat there is a ton of information out there about this.
25th Mar 2017, 2:21 PM
J.G.
J.G. - avatar
0
Look up Knuth-Morris-Pratt and Boyer-Moore Algorithms on Wikipedia.
26th Mar 2017, 7:20 AM
Abhirup Das
Abhirup Das - avatar