I'm trying to convert a character from a string into an int. I tried this :
int function(char c[]) {
return (int)c[1];
}
I want to convert only the second character of the string c, which length is only of two.
The problem with this function is that the integer returned is completely different from what I typed.
I also tried to compare c[1] and numbers from 0 to 10 (only those numbers need to be converted), but there's a problem with c[1].
I hope everything is clear enough so you can help me.
Thanks !!!
Answer : I just changed return(int)c[1];
into return(int)(c[1]-'0');
and that worked well, at least for me