请期待学习如何在Unix中打印当前登录的用户和系统名称。如何在Unix中打印当前用户和系统名称?
#include <unistd.h>
#include <fcntl.h>
using namespace std;
int main(int argc, char **argv)
{
//Print the current logged-in user/username.
//Print the name of the system/computer name.
return 0;
}
如果您能提供一行或两行代码作为演示,我将不胜感激。谢谢
这是一个家庭工作问题吗?你可能应该做一些研究,而不是直接问这样的问题。例如参见http://en.wikipedia.org/wiki/Exec_(operating_system)。 – 2012-01-04 08:29:26
好的..谢谢。 [之间,这不是一项功课]。 – CompilingCyborg 2012-01-04 08:31:01