We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
https://stackoverflow.com/questions/439573/how-to-convert-a-single-char-into-an-int There is a comment in top answer that states that -48 woun't work on every encoding. There is another aspect - your question. Would you have a question if the code was: arr[i][j] - '0' ...? Probably not. In my opinion the use of -48 falls into bad practice. And note: because both operands are subtracted the subtraction itself is obsolete.
Cavity Map
You are viewing a single comment's thread. Return to all comments →
https://stackoverflow.com/questions/439573/how-to-convert-a-single-char-into-an-int There is a comment in top answer that states that -48 woun't work on every encoding. There is another aspect - your question. Would you have a question if the code was: arr[i][j] - '0' ...? Probably not. In my opinion the use of -48 falls into bad practice. And note: because both operands are subtracted the subtraction itself is obsolete.