I am developing an application. One of the methods needs to capture the computer name and user logged on the machine, then display both to the user. I need it to run on both Windows and Linux. What is the best way to do this?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
In Windows environment you can use
getenv("COMPUTERNAME")
,getenv("USERNAME")
In Linux -
getenv("HOSTNAME")
,getenv("USER")
See getenv reference