dcsimg
 

Tip: How to Convert char to int

Wednesday Mar 31st 2021 by Octavia Andreea Anghel
Article Image

Just subtract zero.

Converting char to int can be accomplished by subtracting '0':

char c = '4';
int n = c - '0'; // gives the int value 4
Home
Mobile Site | Full Site