This code was written on the assumption that spaces and string termination character might occur in between words.
Edit:
We don’t really need the if(Word.length() != 0)
thing because I forgot that we have a separate section to check for input’s length. So please ignore the first “if” statement and also its respective “else”.
PS: I implemented it in the case that if length of word is 0, the function will exit, it’s not really needed.