How do I read system information in C++?

后端 未结 4 1321
谎友^
谎友^ 2021-02-04 16:29

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

4条回答
  •  情书的邮戳
    2021-02-04 17:21

    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.

    Example:  man uname:
    SEE ALSO
           uname(2), getdomainname(2), gethostname(2)
    
    
    Explanation of numbers:
    
    (1): User UNIX Command
    (2): Unix and C system calls
    (3): C Library routines
    (4): Special file names
    (5): File formats
    (6): 
    (7):
    (8): System admin commands
    

    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.

提交回复
热议问题