I’m trying to get information like OS version, hard disk space, disk space available, and installed RAM on a Linux system in C++. I know I can use system() to run different Linux commands and capture their output (which is what I’m currently doing) but I was wondering if there’s a better way? Is there something in the C++ standard library that I can use to get information from the operating system?
I’m trying to get information like OS version, hard disk space, disk space available,
Share
If you are using *nix commands via system.
Then do man scroll to the bottom of the man page and it will usually show you what relevant C system calls are related.
So if you are using system(‘uname’). From the man page you can see that there is also a uname C system call (uname(2)). So you can now do a ‘man 2 uname’ to get information about how to use the C system call uname.