#include
#include
#include
/*
struct passwd{
char *pw_name; /*User name*/
char *pw_passwd; /*User password*/
uid_t pw_uid; /*USer ID*/
gid_t pw_gid; /*User group ID*/
char *pw_gecos; /*User Real name*/
char *pw_dir; /*User directect*/
char *pw_shell; /*User's Shell*/
};
*/
int main(int argc,char **argv)
{
pid_t my_pid,parent_pid;
uid_t my_uid,my_euid;
gid_t my_gid,my_egid;
struct passwd *my_info;
my_pid=getpid();
parent_pid=getppid();
my_uid=getuid();
my_euid=geteuid();
my_gid=getgid();
my_egid=getegid();
my_info=getpwuid(my_uid);
printf("Process ID: %ld\n",my_pid);
printf("Parent ID: %ld\n",parent_pid);
printf("User ID: %ld\n",my_uid);
printf("Effective User ID: %ld\n",my_euid);
printf("Group ID: %ld\n",my_gid);
printf("Effective Group ID: %ld\n",my_egid);
if(my_info)
{
printf("My Login Name: %ld\n",my_info->pw_name);
printf("My Password: %ld\n",my_info->pw_passwd);
printf("My User ID: %ld\n",my_info->uid);
printf("My Group ID: %ld\n",my_info->pw_gid);
printf("My Real Name: %ld\n",my_gecos);
printf("My Home Dir: %ld\n",pw_dir);
printf("My Work Shell: %ld\n",pw_shell);
}
return 0;
}
错误:
[root@localhost temp2_process]# cc exercise.c
exercise.c:14: 错误:expected identifier or ‘(’ before ‘}’ token
exercise.c:15: 错误:expected identifier or ‘(’ before ‘/’ token
[root@localhost temp2_process]#
求助
hacker47 于 2009-01-16 09:18:24发表:
这位兄弟已经正解了
hacker47 于 2009-01-16 09:17:26发表:
注释是不能嵌套的.
tkfly0324 于 2008-12-30 13:59:37发表:
怎么回事呢
smqt 于 2008-11-27 19:07:26发表:
通过了?恭喜啊
jifeijixufly 于 2008-11-27 16:29:36发表:
#include
#include
#include
#include
/*
struct passwd{
char *pw_name;
char *pw_passwd;
uid_t pw_uid;
gid_t pw_gid;
char *pw_gecos;
char *pw_dir;
char *pw_shell;
};
*/
int main(int argc,char **argv)
{
pid_t my_pid,parent_pid;
uid_t my_uid,my_euid;
gid_t my_gid,my_egid;
struct passwd *my_info;
my_pid=getpid();
parent_pid=getppid();
my_uid=getuid();
my_euid=geteuid();
my_gid=getgid();
my_egid=getegid();
my_info=getpwuid(my_uid);
printf("Process ID: %ld\n",my_pid);
printf("Parent ID: %ld\n",parent_pid);
printf("User ID: %ld\n",my_uid);
printf("Effective User ID: %ld\n",my_euid);
printf("Group ID: %ld\n",my_gid);
printf("Effective Group ID: %ld\n",my_egid);
if(my_info)
{
printf("My Login Name: %ld\n",my_info->pw_name);
printf("My Password: %ld\n",my_info->pw_passwd);
printf("My User ID: %ld\n",my_info->pw_uid);
printf("My Group ID: %ld\n",my_info->pw_gid);
printf("My Real Name: %ld\n",my_info->pw_gecos);
printf("My Home Dir: %ld\n",my_info->pw_dir);
printf("My Work Shell: %ld\n",my_info->pw_shell);
}
return 0;
}
~
smqt 于 2008-11-26 20:39:34发表:
/*
struct passwd{
char *pw_name; // User name
char *pw_passwd; // User password
uid_t pw_uid; // USer ID
gid_t pw_gid; // User group ID
char *pw_gecos; // User Real name
char *pw_dir; // User directect
char *pw_shell; // User's Shell
};
*/