Convert a string to an integer using a stringstream