Page Actions
Wiki Actions
User Actions
Submit This Story

getpwnam 结构

用户信息一览

The Code

#include <stdio.h>
#include  <stdlib.h>
#include  <sys/types.h>
#include  <pwd.h>
 
int main(int argc, char **argv)
{
  struct passwd *pw;
 
  if(argc <= 1) {
      printf("./getpwuid  \n");
      return 0;
  }
 
  pw = getpwnam(argv[1]);
  if( pw != NULL ) {
    printf("User name %s\n",pw->pw_name);
    printf("user password %s\n",pw->pw_passwd);
    printf("user id %d\n",pw->pw_uid);
    printf("group id %d\n",pw->pw_gid);
    printf("real name %s\n",pw->pw_gecos);
    printf("home directory %s\n",pw->pw_dir);
    printf("shell program %s\n",pw->pw_shell);
 
  } else {
    printf("User not found!\n");
  }
  return 0;
 
}
,

Discussion

Enter your comment
 
 
blog/2009/10/getpwnam_结构.txt · Last modified: 2009/10/01 00:00 (external edit)     Back to top
Recent changes RSS feed Creative Commons License Powered by PHP Driven by DokuWiki