You should not use atoi on a non string array char variable because there is no guarantee of it to be null terminated, so atoi would yield unpredictable results.