CAD教程 行业资讯 3D模型下载 Pro/E教程 CAD书店 软件下载 联系我们
技术资料 CAD招聘 发布招聘 CAD问答 设计竞赛 CAD认证 北京CAD培训
视频教程 PS教程 CAD图纸 图书推荐 Solidworks教程 CAD培训 CAD软件商

 最新视频教程Pro/ENGINEER Wildfire2.0 工业设计实例视频教程 (全套免费在线学习)   AutoCAD视频教程每日更新
 
首页 > CAD在线问答 > 计算机图形学

求牛人帮我看看这道C语言关于process的问题

2010-10-06 51自学网



逻辑很简单,我的第一个.C文件颠倒一个字符串。第2个c文件转换大小写。现在在我的第一个c文件里加上 fork() 产生一个子程序,在这个子程序里进行叫第个文件的操作。主程序等子程序文成后退出。下面是我写的请帮我修改一下: // 主程序#include <stdio.h>#include <string.h>#include <unistd.h>#include <sys/types.h>#define STR_LENGTH 50int main(){ char str[STR_LENGTH]; char *temp; int i; pid_t pid; int status; pid_t s; printf("please insert an single string: "); gets(str); strrev(str); printf("the string entered is: %s/n",str); pid = fork(); if(pid<0) // error occurred { fprintf(stderr,"fork failed"); exit(-1); } else if (pid == 0) // child process { printf("child pid = %d /n", getpid()); if (execl("/bin/proc2.c", "prog2, NULL)<0); { printf( " Command not found /n"); exit(1); } else // parent process { printf(" I am the parent/n"); s = wait(&status); if(s != -1) printf(" Parent detect child process# %d is done/n", s); } return 0;}//被叫的程序#include <stdio.h>#include <string.h>#include <ctype.h>#include <unistd.h>#include <sys/types.h>#define STR_LENGTH 50int main(){ char str[STR_LENGTH]; char *temp; int i; printf("please insert an single string: "); gets(str); for(i=0;i<strlen(str);i++) { if( isupper( str[i])) str[i] = tolower(str[i]); else str[i] = toupper( str[i]); } printf("the string entered is: %s/n",str); return 0;}
测试结果 输入:haPPy 输出:YppAH这就可以了。




 

 

求书<计算机网络——自顶向下方法与Internet特色>
计算机硕士学位论文写什么题目
我来回答 共有条 回答
用户名: 密码:
验证码: 匿名发表
| AutoCAD | Pro/E | UG | 3Dmax | catia | solidworks | maya | photoshop | 模具设计 | 有限元 | matlab | 计算机图形学 | 室内设计 |