我如何获得Linux系统的正常运行?
答
#include <stdio.h>
#include <sys/sysinfo.h>
int main(void)
{
struct sysinfo sys_info;
sysinfo(&sys_info);
printf("Seconds since uptime: %lu\n", sys_info.uptime);
return 0;
}
这应该让你开始。如果您需要更多帮助,请在终端中键入man sysinfo
。
请在发帖前了解搜索答案。当我搜索'[linux]正常运行时间'时,我发现了488个答案,而第三个答案正是你在下面接受的内容。是关于帮助人们修复他们的代码(而不是为他们寻找)。请阅读http://*.com/help/how-to-ask,http://*.com/help/dont-ask,http://*.com/help/mcve并参加[tour]( http://*.com/tour)在发布更多Q之前。谢谢,祝你好运。 – shellter