uptime: Use fgets()
This commit is contained in:
parent
a4eed362b6
commit
31e0f0efed
@ -10,17 +10,15 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
|
||||
char buf[4096];
|
||||
size_t nread = fread(buf, sizeof(buf) - 1, 1, fp);
|
||||
char buf[32];
|
||||
fgets(buf, sizeof(buf), fp);
|
||||
|
||||
if (ferror(fp))
|
||||
{
|
||||
perror("fread");
|
||||
perror("fgets");
|
||||
return 1;
|
||||
}
|
||||
|
||||
buf[nread] = 0; // null terminate it :)
|
||||
|
||||
long ms_uptime = atol(buf);
|
||||
|
||||
printf("up for %ld seconds\n", ms_uptime / 1000);
|
||||
|
Loading…
Reference in New Issue
Block a user