c++ version of word search