问题
How would I go to cast/convert literal char '0'
to int 0
?
i.e.:
char string[] = "0101";
char ch = string[0];
x = magic(ch);
if (x)
printf("int zero")
回答1:
ch = 0;
Now, if you want to convert any digit-character to its numeric equivalent, you'd need something like:
ch = ch - '0';
来源:https://stackoverflow.com/questions/41365518/c-cast-literal-char-0-to-int-0-zero-how