cpp implementation of Length of Last Word