I have the following snippet of a C program:
char line[128];
int io;
FILE *fp = fopen("/proc/diskstats", "r");
while(fgets(line, sizeof line, fp)) {
fputs(line, stdout);
if(dev_t_conversion(line) == get_file_devid("/")) {
sscanf(line, "%*d\t%d", &io);
printf("%d\n", io);
fclose(fp);
}
}
If I remove the fputs(line, stdout);
line, the if
conditional is never reached. I cannot understand why that is. Why do I need to put line
to stdout
?
Aucun commentaire:
Enregistrer un commentaire