#include <stdio.h> int main() { FILE* fp; int n, a[2] = { 65,66 }; char c?

#include <stdio.h>

int main()
{
FILE* fp;
int n, a[2] = { 65,66 };
char ch;

fp = fopen("d.dat", "w");
fprintf(fp,"%d%d", a[0], a[1]);
fclose(fp);
fp = fopen("d.dat", "r");
fscanf(fp, "%c", &ch);
n = ch;
while (n != 0)
{
printf("%d", n % 10);
n = n / 10;
}
fclose(fp);

return 0;
}
请问结果为什么是45?
最新回答
许多

2024-06-06 00:30:49

1.文件内容是6566
2. 第一个字符是'6',值是54
3. 输出是倒序
追问
懂了,多谢,我考虑到65,65对应的A, B,没考虑到%c