I'm writing a grep function in C++ (as a self assigned exercise - I realize this doesn't have the functionality of an actual grep feature) to take an original string and the search string you are looking for. In the code, I enter all the characters in a grep string up to the first space it sees. Then I compare the characters in the grep string with the search string, and if it matches, store it in a temp string. I loop over the grep string and compare the length of the search string with the temp string to see if it matches.I'm writing a grep function in C++ (as a self a