Created
September 2, 2014 22:38
-
-
Save tnachen/cac461f0285acc5eefd5 to your computer and use it in GitHub Desktop.
sysinfo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <iostream> | |
#include <sys/sysinfo.h> | |
#include <errno.h> | |
int main(int argc, char** argv) | |
{ | |
struct sysinfo info; | |
if (sysinfo(&info) != 0) { | |
return errno; | |
} | |
std::cout << "Total:" << info.totalram * info.mem_unit << std::endl; | |
std::cout << "Free:" << info.freeram * info.mem_unit << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment