【精品】Linux程序设计基础实验指导

【精品】Linux程序设计基础实验指导

ID:46479394

大小:134.50 KB

页数:15页

时间:2019-11-24

【精品】Linux程序设计基础实验指导_第1页
【精品】Linux程序设计基础实验指导_第2页
【精品】Linux程序设计基础实验指导_第3页
【精品】Linux程序设计基础实验指导_第4页
【精品】Linux程序设计基础实验指导_第5页
资源描述:

《【精品】Linux程序设计基础实验指导》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、Linux程序设计基础一C环境一VI编辑器的使用使用VI编辑下列几个函数文件:hello.hstarfun.hhello.cstaccStarfun.h文件内容如下:/*****starfunh*****/#ifndefSTARFUN_H#dcfincSTARFUN_H#defineNUM4#defineNUMBER3intstarl(){intij.k;for(k=l;k<=NUM;++k){for(i=l;i<=(NUM-k);++i)pnntfC1");for(j=l;j<=(2*k-l);++j)print"*”);printf(uH);)re

2、turn0;}intstar2(){inti,j,k;for(k=NUMBER;k>=0;-k){for(i=1;i<=(NUMBER-k+1);++i)printf(-“);for(j=l;j<=(2*k-l);++j)print”*”);printf(u");}return0;#endifhello.h文件内容如下:/*hello.h*/#ifndefHELLO.H#defineHELLOHvoidhello(){star1();printf(''hello,myfriends");)#endifhello.c文件内容如下:voidshowhe

3、llo(){hello();}star.c文件内容如下:#includc"starfun.hn#include"hello.h"#includeintmain(){star1();star2();showhello();return0;}Vi编辑器的使用,可以参考PPT,在使用Vi编辑器的过程中,注意使用Vi的-单行和多行复制命令,练习字符串查找替换命令,删除一个字符,删除光标后整个内容命令,删除一行命令,恢复删除,保存和退出命令筹命令,并尝试使用英他命令。掌握#ifndefSTARFUN.H#defineSTARFUN_H的宏定义用法二

4、.使用gCC编译器,编译程序第一种方法:分步进行1.illstar.cstarfun.h文件生成star.o目标文件gcc-cstar.c-ostar.o2.illhello.chello.hstarfun.h生成hello.o目标文件gcc-chello.c-ohello.o3.由hello.ostar.o生成应用程序myproggccstar.ohello.o-omyprog[root@localhost01_helloJ#./myprog****rTwrT^rT^rY*rjwrT*rTwrTwrTw****vl#"卜・p9n・p9nhello,myf

5、riends第二种方法:一条命令完成以上操作gccstacchello.c-omyprog结合本次课的PPT关于gcc部分,体会gcc编译器编译的过程,并在实验报告中描述在以上编译中尝试[root@localhost01_hcllo]#gccstar.chcllo.c-omyprog[root@localhostOl^hello]#gcc-wstarehello.c・omyprog[root@localhost01_hello]#gcc-Wallstar.chello.c-omyprogInfileincludedfromstar.c:1:starfun.

6、h:Infunction"starl1:starfun.h:13:warning:implicitdeclarationoffunctionxprintfstar.c:Infunction"main1:star.c:8:warning:implicitdeclarationoffunction'showhello'hello.c:Infunction"showhello1:hello.c:4:warning:implicitdeclarationoffunction、hello°体会・Wall・w选项的作用查阅当前的gcc版本命令[root@localho

7、st01_hello]#gcc-vReadingspecsfrom/usr/lib/gcc-lib/i386-redhat-linux/3.2>2/specsConfiguredwith:../configure-prefix=/usr—mandir=/usr/share/man—infodir=/usr/share/info-enable-shared・-enable-threads=posix-disable-checking-with-system-zlib・-enable-—cxa_atexit—host=i386-redhat-IinuxThre

8、admodel:posixgccversion3222003022

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。