QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 783|回复: 3

帮帮我,谢谢

[复制链接]
发表于 2005-6-24 22:04:20 | 显示全部楼层 |阅读模式
在liunx系统中编写 C语言程序, 创建一个子进程。父进程和子进程交替运行。父进程先显示一次“current time”,然后子进程每隔一秒显示一次当前系统日期和时间,共显示三次。以上过程共循环进行5次。
谁会这个啊,教  教 我,谢谢
发表于 2005-6-25 09:22:51 | 显示全部楼层
题目写的很清楚阿,自己编来试试,然后贴出你的代码,再共同研究,怎么样?
回复

使用道具 举报

 楼主| 发表于 2005-6-25 12:03:31 | 显示全部楼层
#include <stdio.h>
#include <unistd.h>
#include <time.h>
int main(int argc,char *argv)
{int i,pid;
  pid=fork();
  time_t t;
  time(&t);
  if(pid>0)
  printf("today's date and time:%s\n",ctime(&t));
  wait()
  else
      {if(pid=0)
        for(i>0,i<4,i++)
       printf("today's date and time:%s\n",ctime(&t));
      exit(1)
             }
}
这个程序是我本人写的,不过有错,不会改,那位帮我改一下了啊,谢谢
回复

使用道具 举报

 楼主| 发表于 2005-6-25 12:20:40 | 显示全部楼层
zhy2111314, #include <stdio.h>
#include <unistd.h>
#include <time.h>
int main(int argc,char *argv)
{int i,pid;
  pid=fork();
  time_t t;
  time(&t);
  if(pid>0)
  printf("today's date and time:%s\n",ctime(&t));
  wait()
  else
      {if(pid=0)
        for(i>0,i<4,i++)
       printf("today's date and time:%s\n",ctime(&t));
      exit(1)
             }
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-10-6 14:13 , Processed in 0.038255 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表