这也解释了上面这段代码能判断编译器默认char类型。
char型数字转换为int型
转换方法
- a[i] - '0'
参考程序
- #include <stdio.h> #include <stdlib.h>
- #include <string.h>
- int main() {
- char str[10]; int i, len;
- while(scanf("%s", str) != EOF)
- { for(i = 0, len = strlen(str); i < len; i++)
- { printf("%d", str[i] - '0');
- } printf("n");
- }
- return 0; }










