Update chapter01.cpp

Validate the input argument "str". If it is not correctly set (str.length() < 1), just return the function . And if it contains only one character (str.length() == 1), again we just return the function.