Get information about system?

Hi,

I need get information about operation system, how memory, cpu and disk.
But, I don't find any lib that to do it. So, I cretate a simple program to execute any commands to find any information, like: memoria total.
But, don't save the answer link variable.

Anybody, to know like get information of system and to save any variable?

How I save the answer o system() in a variable:
My code:

1
2
3
4
5
6
7
8
9
10
11
#include <cstdlib>
#include <iostream>
#include <cstdio>
using namespace std;

int main(int argc, char** argv) {

    system("cat /proc/meminfo | grep MemTotal | awk '{ print $2 }'");

    return 0;
}


Tks.
How I save the answer o system() in a variable:
system() doesn't allow that (best you can do is redirect to a temporary file and read that file later). However, popen() lets you run a command and examine its output.
Last edited on
closed account (Dy7SLyTq)
/proc is where that stuff is
Topic archived. No new replies allowed.