我正在尝试逐行读取文本文件并打印前 17 个字符。
FILE *devices;
devices = NULL;
devices = fopen("devices.txt", "r");
char deviceaddr[17];
char addr[17];
char line[1024];
while (fgets(line,1024,devices) != NULL)
{
fscanf(devices,"%s", deviceaddr);
printf("%s\n", deviceaddr);
}
fclose(devices);
输出应该是00:07:80:4C:0E:EE
第一行,但它给出了6
.