23,121
社区成员
发帖
与我相关
我的任务
分享
int n;
int fd[2];
pid_t pid;
char line[MAXLINE];
FILE *fp;
if (pipe(fd) < 0)
err_sys("pipe error");
if ((pid = fork()) < 0) {
err_sys("fork error");
} else if (pid > 0) { /* parent */
close(fd[0]);
write(fd[1], "0911612504\n", 10);
fp = fdopen(fd[1], "w+");
fflush(fp);
write(fd[1], "19920820\n", 8);
} else { /* child */
close(fd[1]);
dup2(fd[0], STDIN_FILENO);
execl("a.out", 0);
}
void main()
{
char usr[10];
char pwd[10];
printf("Please input your username:");
scanf("%s", usr);
printf("Please input your password:");
scanf("%s", pwd);
printf("User Name: %s\nPassword: %s\n", usr, pwd);
}