getlogin()

getlogin()是一種計算機函式,頭檔案為#include。

頭檔案

#include<sys/types.h>

#include<unistd.h>

函式原型

char *getlogin(void);

說明

char *getlogin(void);

說明

getlogin() returns a pointer to a string containing the name of the user logged in on the controlling terminal of the process, or a null pointer if this information cannot be determined. The string is statically allocated and might be overwritten on subsequent calls to this function or to cuserid().

範例

#include <sys/types.h>

#include <stdio.h>

#include <unistd.h>

int main()

{

uid_t uid;

gid_t gid;

uid = getuid();

printf("User is %s\n", getlogin());

printf("User IDs: uid=%d,\n", uid);

exit(0);

}

相關詞條

熱門詞條

聯絡我們