cpp implementation of string to integer