这是我的代码摘录。它读取一个文件并将第一行放入一个char
,然后将第一行的一部分放入一个int。该文件的第一行是“10 20”。该文件稍后会关闭。我打印temp时的输出是10 20,但是当我打印rct时,它是49,cct是32.我对c完全陌生,并不知道为什么这是错误的。为什么我的C程序显示的不是int应该是
FILE *matrix;
char *temporary = argv[5];
matrix = fopen(temporary,"r");
if (matrix == NULL)
{
perror(argv[5]);
exit(1);
}
int rct, cct;
char temp[10];
fgets (temp, 10, matrix);
rct = temp[0];
cct = temp[2];
请发布一个MCVE,而不是一些代码不能用来诊断错误。 – Deduplicator 2014-10-30 14:13:17
从我的答案'摘录':你可以通过解决这个问题。 。 。 。 。 。 – 2014-10-30 14:16:21