我试图通过这段代码读取未知数量的整数:
while (1) {
int c = getchar ();
if (c == EOF)
break;
else if (isdigit (c))
current = current * 10 + (c - '0');
else {
total += current;
current = 0;
}
}
Run Code Online (Sandbox Code Playgroud)
我知道是什么current = current * 10 + (c - '0'); 但我不知道为什么会这样c - '0'.你能解释一下吗?先感谢您.