1847405 Members
2938 Online
110264 Solutions
New Discussion

Re: Getuid function

 
SOLVED
Go to solution
Krishnan Viswanathan
Frequent Advisor

Getuid function

I am writing a small c code.
Is there a function which gives the username directly instead of uid ?

Thanks
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Getuid function

Hi:

You can use the getlogin function, although the proper procedure is to call getlogin(); if that returns a NULL then you should call getpwuid(getuid()) to return a pointer to a passwd struct.

Man 3 getlogin, getpwuid for details.

Regards, Clay
If it ain't broke, I can fix that.