[英]fgetc returning unexpected value 49 when 1 is expected
我在使用fgetc函數從文件中讀取值時遇到麻煩。 這是我正在使用的代碼:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int k;
FILE* rede = fopen("/home/leocal/Desktop/Poli/2018-1/Numérico/EP1/Redes/1_Stevenson/a.txt", "r");
if (rede == NULL) {
printf("Couldn't open file\n");
return 1;
}
k = fgetc(rede);
if (k!=EOF) {
printf("printing k : %d",k);
}
fclose(rede);
return 0;
}
文件“ a.txt”具有單個字符“ 1”,但是k
接收值49。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.