2019-04-12 :-|
_ [uptime]uptime 取得して 時:分 を印字
% uname -rsm Linux 4.20.8-arch1-1-ARCH x86_64
#include <stdio.h> int main(int ac, char** av) { FILE* fp; double uptime; double idletime; double t; int h, m; if((fp = popen("cat /proc/uptime", "r"))) { fscanf(fp, "%lf%lf", &uptime, &idletime); fclose(fp); t = uptime / 3600; h = (int)t; m = (int)((t - floor(t)) * 60); printf("uptime: %lf %d:%d\n", uptime, h, m); } return 0; }
% gcc uptime.c % ./a.out ; uptime uptime: 10309.300000 2:51 12:25:50 up 2:51, 1 user, load average: 0.55, 0.35, 0.43
[ツッコミを入れる]