Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

cuserid - get login name

&pagelevel(4)&pagelevel

Syntax

#include <stdio.h>

char *cuserid(char *s); 

Description

cuserid() generates a character representation of the name associated with the real
user ID of the current process.

If s is a null pointer, this string is generated in an area that may be static and thus overwritten
by subsequent calls to cuserid(). The address of this area is returned.

If s is not a null pointer, s is assumed to point to an array of at least {L_cuserid} bytes,
and the string representation of the login name is placed in this array. The symbolic
constant {L_cuserid} is defined in stdio.h and has a value greater than 0.

cuserid() is not thread-safe.

Return val.

s

if s is not a null pointer. If the login name cannot be found, the null byte 0 will
be placed at *s .

Address of the buffer containing the login name 


if s is a null pointer and the login name can be found.

Null pointer

if s is a null pointer and the login name cannot be found.

Notes

The functionality of cuserid() defined in the POSIX.1-1988 standard and XPG3 differs
from that of historical implementations and XPG2. In the ISO POSIX-1 standard, the
cuserid function has been removed entirely. Both functionalities are allowed in XPG4, but
both are also marked to be withdrawn.

The XPG2 functionality can be obtained by using the following syntax:

getpwuid(getuid())

The XPG3 functionality can be obtained by using the following syntax:

getpwuid(geteuid())

See also

getlogin(), getpwnam(), getpwuid(), getuid(), geteuid(), stdio.h, and the
manual "POSIX Basics" [1 (Related publications)].