hi there, i just want to know what function to use in converting a char into an int
char temp; cout << "enter something"; cin >> temp; atoi(temp);
is this the right way?
>>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: [inlinecode]int n = temp - '0';[/inlinecode]. Why does that work? … Read More
Edited by Mahkoe: n/a
Edited by WaltP: n/a