>>is this the right way?
No because atoi() takes a pointer to a null-terminated string and your variable temp is just a single character.
The quickest way is to simply subtract the ascii value of '0' from it like this: int n = temp - '0'; . Why does that work? Its because a char is a small integer and if you look at an ascii chart you will see that all characters have an ascii numerical value. Internally, programs know nothing at all about characters, only numeric values as shown in that ascii chart.
yes that is a correct way u can proceed.........
but the only thing u need to do is that u should use char array in place of char variable, and the function atoi is return an int value so u should store the result in some integer variable.
cout<<i; \\ the output = 20;