当前位置: 首页 > news >正文

北京免费网站建设模板下载南江县建设局网站

北京免费网站建设模板下载,南江县建设局网站,萍乡做网站的公司有哪些,哈尔滨网站建设团队1#xff1a;编写链表#xff0c;链表里面随便搞点数据 使用 fprintf 将链表中所有的数据#xff0c;保存到文件中 使用 fscanf 读取文件中的数据#xff0c;写入链表中#xff0c;实现#xff0c;当按 ctrl c的时候#xff0c;保存链表 #include stdio.h #in…1编写链表链表里面随便搞点数据 使用 fprintf 将链表中所有的数据保存到文件中 使用 fscanf 读取文件中的数据写入链表中实现当按 ctrl c的时候保存链表 #include stdio.h #include string.h #include unistd.h #include stdlib.h #include sys/types.h #include sys/stat.h #include fcntl.h #include pthread.h #include semaphore.h #include signal.h typedef struct link_list {int data;struct link_list *next; }lis,*linkp;linkp p NULL;void insert(int data) {linkp new (linkp)malloc(sizeof(lis));if(newNULL){perror(NULL);return;}new-datadata;new-next p;p new; } void reads() { FILE* rfp fopen(data.txt, r); if (rfp NULL) { perror(reading); return; } int a; while (fscanf(rfp, %d, a) ! EOF) { insert(a); } fclose(rfp); printf(链表已根据data.txt文件更新\n); } void savefun() { FILE *file fopen(save.txt, w); if (file NULL) { perror(writing); return; } linkp q p; while (q) { fprintf(file, %d\n, q-data); q q-next; } fclose(file); printf(链表已保存到save.txt文件中\n); } void handler(int signo) { if (signo SIGINT) { printf(按下ctrlc后链表结果,存在save.txt中\n); savefun(); } exit(0); } int main(int argc, const char *argv[]) { signal(SIGINT, handler); insert(12); insert(34); insert(56); insert(78); reads(); printf(头插法写入链表完成\n); while (1) { //收到SIGINT信号} return 0; }2编写2个.c文件生成2个可执行文件 1.c 输入正方形的长和宽 或者 三角形的三边长 2.c 输出长方形或者三角形的面积 要求数据通信使用无名管道实现 in.c #include stdio.h #include string.h #include unistd.h #include stdlib.h #include sys/types.h #include sys/stat.h #include fcntl.h #include pthread.h #include semaphore.h #include wait.h int main(int argc, const char *argv[]) {float buf[3];int pipefd[2] {0};pid_t pid;if(pipe(pipefd)-1){perror(pipe);return 1;}char std[2];std[0]pipefd[0];std[1]pipefd[1];pid fork();if(pid-1){perror(fork);return 1;}if(pid0){execlp(./area,2,(std[0]),(std[1]),NULL);perror(execlp);exit(0);}else{printf(输入正方形的长和宽 或者 三角形三边 \n);printf(tips:如果是正方形第三个数输入0\n);scanf(%f %f %f,buf[0],buf[1],buf[2]);write(pipefd[1],buf,sizeof(buf));wait(NULL);close(pipefd[0]);close(pipefd[1]);}return 0; }area.c #include stdio.h #include string.h #include unistd.h #include stdlib.h #include sys/types.h #include sys/stat.h #include fcntl.h #include pthread.h #include semaphore.h #include math.h int main(int argc, const char *argv[]) {float a,b,c;double area;int rp*(argv[1]);int wp*(argv[2]);if (read(rp,a,sizeof(a)) -1) {perror(read a);return 1;}if (read(rp,b,sizeof(b)) -1) {perror(read b);return 1;}if(read(rp,c,sizeof(c)) -1){perror(read c);return 1;}if (c0){if(ab){// 正方形的面积area a * b;printf(正方形的面积为%.2f\n, area);}else{printf(输入长方形\n);}}else {// 三角形的面积海伦公式double p (a b c) / 2.0;area sqrt(p * (p - a) * (p - b) * (p - c));printf(三角形的面积为%.2f\n, area);} return 0; }3使用有名管道实现2个终端之间的互相聊天功能 要求能够并发 #include stdio.h #include string.h #include unistd.h #include stdlib.h #include sys/types.h #include sys/stat.h #include fcntl.h #include pthread.h #include semaphore.h int main(int argc, const char *argv[]) {if(mkfifo(./myfifo1, 0664) -1){perror(mkfifo1 error);return -1;}if(mkfifo(./myfifo2, 0664) -1){perror(mkfifo2 error);return -1;}getchar();system(rm myfifo1);system(rm myfifo2);return 0; } #include stdio.h #include string.h #include unistd.h #include stdlib.h #include sys/types.h #include sys/stat.h #include fcntl.h #include pthread.h #include semaphore.hint main(int argc, char const *argv[]) {pid_t pidfork();if(pid0){int wfd -1;if((wfd open(./myfifo1, O_WRONLY)) -1){perror(open error);return -1;}char wbuf[128] ;while(1){printf(这里是1号机,请输入);fgets(wbuf, sizeof(wbuf), stdin);wbuf[strlen(wbuf)-1] 0;write(wfd, wbuf, strlen(wbuf));if(strcmp(wbuf,quit) 0)break;}close(wfd); }else if(pid0){int rfd -1;if((rfd open(./myfifo2, O_RDONLY)) -1){perror(open error);return -1;}char rbuf[128] ;while(1){bzero(rbuf, sizeof(rbuf));read(rfd, rbuf, sizeof(rbuf));printf(\t\t\t\t\t1号机收到的数据为%s\n, rbuf);if(strcmp(rbuf,quit) 0)break;}close(rfd);exit(EXIT_SUCCESS);}elseperror(fork); return 0; }#include stdio.h #include string.h #include unistd.h #include stdlib.h #include sys/types.h #include sys/stat.h #include fcntl.h #include pthread.h #include semaphore.h int main(int argc, char const *argv[]) {pid_t pidfork();if(pid0){int rfd -1;if((rfd open(./myfifo1, O_RDONLY)) -1){perror(open error);return -1;}char rbuf[128] ;while(1){bzero(rbuf, sizeof(rbuf));read(rfd, rbuf, sizeof(rbuf));printf(\t\t\t\t\t2号机收到的数据为%s\n, rbuf);if(strcmp(rbuf,quit) 0)break;}close(rfd); }else if(pid0){int wfd -1;if((wfd open(./myfifo2, O_WRONLY)) -1){perror(open error);return -1;}char wbuf[128] ;while(1){printf(这里是2号机,请输入);fgets(wbuf, sizeof(wbuf), stdin);wbuf[strlen(wbuf)-1] 0;write(wfd, wbuf, strlen(wbuf));if(strcmp(wbuf,quit) 0)break;}close(wfd); exit(EXIT_SUCCESS);}elseperror(fock); return 0; }
http://www.zqtcl.cn/news/286493/

相关文章:

  • 温岭手机网站建设义乌市网站建设
  • 西安网站制作费用哪家装修公司比较好的
  • 硅谷网站开发薪酬wordpress热门吗
  • 红酒营销型网站建设天一建设网站
  • 做网站建设公司哪家好安徽省住房建设部官方网站
  • 网站被黑咋样的柳州正规网站制作公司哪家好
  • 莱芜网站开发代理四川网络推广服务
  • 应该知道的网站网站全网建设莱芜
  • 北京网站页设计制作广州专业网站改版
  • 重庆网站建设建站收费免费外链网盘
  • 做加盟代理的网站比较好的网页网站设计
  • 兴义网站开发企业标准备案平台官网
  • 蓝彩网络科技_齐齐哈尔微信营销_齐齐哈尔网站建设会员卡管理系统哪里买
  • 织梦门户网站做大后建个人免费网站用哪个
  • 深圳市建设管理中心西安官网seo
  • 网站开发工作方案自己做的网站怎么维护
  • 潍坊建设部门管理网站做网站如何接单
  • 定制高端网站建设设计建立的近义词
  • 企业网站建设进度邢台163官网
  • 17做网店网站池尾替代wordpress 搜索
  • 网站建设资料 优帮云商品分类标准
  • 鄂尔多斯 网站建设俐侎族网站建设背景
  • 佛山专业网站建设公司上海公司官网
  • 那里做网站好网站模板 登陆
  • 网站的服务器打不开wordpress 修改默认路径
  • 外贸网站做几种产品合肥网络公司哪个最好
  • 长乐区建设局网站一般通过什么渠道了解防灾减灾知识
  • 泰安商城网站开发设计什么网站备案比较快
  • 织梦网站修改首页图片网站名称去哪里注册
  • 电脑版 做网站尺寸怎么查找网站后台