getlogin()是一種計算機函式,頭檔案為#include<sys/types.h>。
基本介紹
- 外文名:getlogin()
- 頭檔案:#include<sys/types.h>
- 函式原型:char *getlogin(void);
- 範例:#include <sys/types.h>
頭檔案,函式原型,說明,說明,範例,
頭檔案
#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);
}
