getpwuid


#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <pwd.h>
int main (void)
{
       struct passwd *passwd;
       passwd=getpwuid(getuid());
       /** passwd=getcwnam("phpos"); **/
       printf("Username:%s/n",passwd->pw_name);
       printf("Password:%s/n",passwd->pw_passwd);
       printf("uid:%d/n",passwd->pw_uid);
       printf("gid:%d/n",passwd->pw_gid);
       printf("shell:%s/n",passwd->pw_shell);
       printf("dir:%s/n",passwd->pw_dir);
       return 0;
}

posted @ 2012-02-20 13:38  greencolor  阅读(282)  评论(0编辑  收藏  举报