請期待學習如何在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