歡迎您光臨本站 註冊首頁

一個進程入門程序,編譯不能通過,網上沒有答案,求助

←手機掃碼閱讀     火星人 @ 2014-03-26 , reply:0

#include
#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]#

求助

[火星人 ] 一個進程入門程序,編譯不能通過,網上沒有答案,求助已經有353次圍觀

http://coctec.com/docs/linux/show-post-185401.html