欢迎来到天天文库
浏览记录
ID:51888933
大小:141.00 KB
页数:17页
时间:2020-03-18
《linux程序设计基础—c环境.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、Linux程序设计基础一C环境一VI编辑器的使用使用VI编辑下列几个函数文件:hello.hstarfun.hhello.cstar.cStarfun.h文件内容如下:/*****starfun.h*****/#ifndefSTARFUN_H#defineSTARFUN_H#defineNUM4#defineNUMBER3intstar1(){intij.k;for(k=l;k<=NUM汁+k){for(i=1;i<=(NUM-k);++i)print"“);for(j=1;j<=(2*k-l);++j)printf(,,*n);printf(uH);)return0;}intstar2
2、(){intij,k;for(k=NUMBER;k>=0;-k){for(i=1;i<=(NUMBER-k+l);++i)printf("“);for(j=1;j<=(2*k-l);++j)printf(,,*H);printf(,fH);}return0;}#endifhello.h文件内容如下:/*hello.h*/#ifndefHELLO.H#defineHELLOHvoidhello(){star1();printf("hello,myfriends");}#cndifhcllo.c文件内容如下:voidshowhello(){hcllo();}star.c文件内容如下:#i
3、ncludc"starfun.h"include”hcllo.h"#includcintmain(){star1();star2();showhello();return0;}Vi编辑器的使用,可以参考PPT,在使用Vi编辑器的过程中,注意使用Vi的单行和多行复制命令,练习字符串查找替换命令,删除一个字符,删除光标后整个内容命令,删除一行命令,恢复删除,保存和退出命令等命令,并尝试使用其他命令。掌握#ifndefSTARFUN_H#defineSTARFUN_H的宏定义用法二・使用gCC编译器,编译程序第一种方法:分步进行1.由star.cstarfun.h文件生成star
4、.oH标文件gcc-cstar.c-ostar.o2.由hello.chello.hstarfun.h生成hello.o0标文件gcc-chello.c-ohello.o3.由hello.ostar.o生成应用程序myproggccstar.ohello.o-omyprog[root@localhost01_helloJ#./myprog*rTerYwrTwrTwrTerY«rTw*******丄"^X9k1><£>•Tw•!•5、gee编译器编译的过程,并在实验报告中描述在以上编译中尝试[root@localhost01_hello]#geestar.chello.c・omyprog[root@localhost01_hcllo]#gee-wstar.chcllo.c・omyprog[root@localhost01_hello]#gee-Wallstar.chello.c-omyprogInfileincludedfromstar.c:1:starfun.h:InfunctionvstarT:Starfun.h:13:warning:implicitdeclarationoffunction"printfstar.6、c:Infunction"main1:star.c:8:warning:implicitdeclarationoffunction"showhcllo1hello.c:Infunction'showhello':hello.c:4:warning:implicitdeclarationoffunctionvhello1体会・W11・w选项的作用查阅当前的gee版本命令[root@iocalhost01_hello]#gee-vReadingspecsfrom/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specsConfiguredwith:../conf7、igure-prefix=/usr—mandir=/usr/share/man・-infodii-/usr/share/info-enable-shared—enable-threads=posix-disable-checking—with-system-zlib-enable-—cxa_atexit・-host=i386-redhat-linuxThreadmodel:posixgeeversion3.2
5、gee编译器编译的过程,并在实验报告中描述在以上编译中尝试[root@localhost01_hello]#geestar.chello.c・omyprog[root@localhost01_hcllo]#gee-wstar.chcllo.c・omyprog[root@localhost01_hello]#gee-Wallstar.chello.c-omyprogInfileincludedfromstar.c:1:starfun.h:InfunctionvstarT:Starfun.h:13:warning:implicitdeclarationoffunction"printfstar.
6、c:Infunction"main1:star.c:8:warning:implicitdeclarationoffunction"showhcllo1hello.c:Infunction'showhello':hello.c:4:warning:implicitdeclarationoffunctionvhello1体会・W11・w选项的作用查阅当前的gee版本命令[root@iocalhost01_hello]#gee-vReadingspecsfrom/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specsConfiguredwith:../conf
7、igure-prefix=/usr—mandir=/usr/share/man・-infodii-/usr/share/info-enable-shared—enable-threads=posix-disable-checking—with-system-zlib-enable-—cxa_atexit・-host=i386-redhat-linuxThreadmodel:posixgeeversion3.2
此文档下载收益归作者所有