cpp implementation of Word Search