操作系统实验之Linux下的C程序开发

上传人:凄****戚 文档编号:183074418 上传时间:2021-05-28 格式:DOCX 页数:18 大小:2.33MB
返回 下载 相关 举报
操作系统实验之Linux下的C程序开发_第1页
第1页 / 共18页
操作系统实验之Linux下的C程序开发_第2页
第2页 / 共18页
操作系统实验之Linux下的C程序开发_第3页
第3页 / 共18页
操作系统实验之Linux下的C程序开发_第4页
第4页 / 共18页
操作系统实验之Linux下的C程序开发_第5页
第5页 / 共18页
点击查看更多>>
资源描述

《操作系统实验之Linux下的C程序开发》由会员分享,可在线阅读,更多相关《操作系统实验之Linux下的C程序开发(18页珍藏版)》请在金锄头文库上搜索。

1、xxx信息科学技术学院2017计算机专业操作系统及安全实验报告姓名xxx学号xxxxxxx专业班级计算机类x班成绩实验报告题目实验02 Linux下的C程序开发教师评语实验报告内容如下:(适当大小的截图)本次实验以一个简单的C程序为例,请用GCC进行编译并运行。例子由两个文件组成:main.c, calc.c,其中,main.c文件内容为:#include int calc(int);int main(int argc, char* argv)int iInput=0, iOutput=0;int i=0;scanf(%i,&iInput);while(iInput 0)printf(Plea

2、se input a positive integer!n);scanf(%i,&iInput);iOutput = calc(iInput);printf(Result is:%in, iOutput);return 0;calc.c的文件内容为:#include int calc(int iIn)int i = 0, iOut = 0;iOut = iIn;for(i = 0; i iIn; i+)iOut += iOut * iIn;return iOut;(一)、用VI编辑器输入以下程序,用gcc编译、运行并截图。程序1:createFork.c#include #include#in

3、cludeint main( )int p1,p2;while(p1=fork( ) = -1); /*创建子进程p1*/if (p1= =0) putchar(b); else while(p2=fork( ) = = -1); /*创建子进程p2*/if(p2 =0) putchar(c); else putchar(a); return 0;程序 2:anotherFork.c#include #include#includeint main( )int p1,p2,i;while(p1=fork( ) = -1); /*创建子进程p1*/if (p1 =0) for(i=0;i10;i

4、+)printf(daughter %dn,i);else while(p2=fork( ) = -1); /*创建子进程p2*/if(p2= =0) for(i=0;i10;i+) printf(son %dn,i);else for(i=0;i10;i+) printf(parent %dn,i);return 0;(二)、用VI编辑器输入以下程序,用g+编译并运行。程序 1:helloCPP.cpp#includeusing namespace std;int main()couthello!endl;coutWelcome to c+!endl;return 0;程序 2:isLeapYear.cpp#include using namespace std;int main()int year;bool IsLeapYear;cout year;IsLeapYear = (year % 4 = 0 & year % 100 != 0) | (year % 400 = 0);if (IsLeapYear) cout year is a leap year endl;else cout year is not a leap year ”使用符号追加新内容的例子;(8) 查找my ,my1,my2和my3中有没有包含salary,ab、cd的行,有几个文件包含ab。

展开阅读全文
相关资源
相关搜索

当前位置:首页 > IT计算机/网络 > linux/Unix相关

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号