【正文】
ootlocalhost ~] gcc o 4_2 :43:2: warning: no newline at end of file[rootlocalhost ~] ./4_2child failed.43 [rootlocalhost ~] gcc o father : In function `main39。實(shí)驗(yàn)內(nèi)容與步驟(1)使用Vi將程序清單41的程序輸入、編譯并運(yùn)行,學(xué)習(xí)和掌握f(shuō)ork的基本調(diào)用方法。(1) 學(xué)習(xí)和掌握f(shuō)ork等系統(tǒng)調(diào)用的基本使用方法。 if(write(fd,buf2,10)!=10) err_exit(file write buf2 error!)。 if(write(fd,buf1,10)!=10) err_exit(file write buf1 error!)。}int main(void){int fd。void err_exit(char *err_s){ perror(err_s)。}//程序清單 34include include include include sys/include sys/char buf1[] = abcdefghij。 if(fwrite(buf2,strlen(buf2),1,fp)!=1) err_exit(file write buf2 error!)。 if(fwrite(buf1,sizeof(buf1),1,fp)!=1) err_exit(file write buf1 error!)。}int main(void){FILE *fp。void err_exit(char *err_s){ perror(err_s)。}//程序清單 33include include include include sys/include sys/char buf1[] = abcdefghij。 write(out,amp。// while((nread = read(in,block,sizeof(block))) 0) while((nread = read(in,amp。 out = open(, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR)。 int nread。 char c。while((c = fgetc(in))!=EOF)fputc(c,out)。 exit(0)。FILE *in,*out。對(duì)linux下編程有所認(rèn)識(shí)。}。 short int sex。 修改之前的系統(tǒng)時(shí)間: [rootlocalhost ~] time ./ list3_2real user sys 修改之后的時(shí)間:___[rootlocalhost ~] time ./list3_2real user sys (5)輸入、編譯并運(yùn)行程序33和34,寫(xiě)出執(zhí)行結(jié)果,并比較他們fseek和lseek在使用方法上的異同程序3的 運(yùn)行結(jié)果是 : 文件的內(nèi)容為:abcdefghij(6)學(xué)習(xí)并分別使用標(biāo)準(zhǔn)C的文件操作函數(shù)和Linux的系統(tǒng)調(diào)用創(chuàng)建一個(gè)對(duì)學(xué)生基本信息進(jìn)行操作(插入、修改和刪除)的C程序,struct stu_info的定義如下:struct stu_info { char stu_num[12]。答:一個(gè)是底層的系統(tǒng)調(diào)用,另一個(gè)是庫(kù)函數(shù)調(diào)用,其效率略有差距,同時(shí)參數(shù)也不同。(2)利用gcc分別編譯這兩個(gè)程序,寫(xiě)出編譯命令和執(zhí)行結(jié)果,如果不成功,嘗試?yán)胓db調(diào)試。(3) 編寫(xiě)并實(shí)現(xiàn)實(shí)驗(yàn)步驟6要求的程序。(1) 學(xué)習(xí)和掌握gcc等Linux的開(kāi)發(fā)調(diào)試環(huán)境。 *) echo e \t\007 unkown user response 。 H|h) cat aaaThis is the help screen,nothing here yet to help you!aaa。 2) file_run 。/^d/ {print $8}39。{print $1}39。 Echo“there are ‘who|wc l’ users online” for i in “who are\n’who|awk’ {print $1}” do echo –n $i echo –n”” done3. 實(shí)驗(yàn)總結(jié)通過(guò)本次實(shí)驗(yàn)對(duì)linux下的文件編輯器vi有初步了解,掌握了基本使用方法,此外初識(shí)shell編程,對(duì)腳本文件有所認(rèn)識(shí)。then echo $i fi done (5) 修改程序中的函數(shù)uers(),使得顯示在線(xiàn)用戶(hù)時(shí)不分行。(4) 閱讀程序,掌握shell函數(shù)的編寫(xiě)方法,補(bǔ)全函數(shù)file_run。(2) 嘗試運(yùn)行該程序,如果不能運(yùn)行,原因是什么,怎樣修改。(8)嘗試存盤(pán)退出操作,寫(xiě)出命令。(6)嘗試復(fù)制/刪除其中的一個(gè)單詞或幾個(gè)字符,寫(xiě)出命令及執(zhí)行結(jié)果。實(shí) 驗(yàn) 報(bào) 告組別姓名同組實(shí)驗(yàn)者實(shí)驗(yàn)項(xiàng)目名稱(chēng)實(shí)驗(yàn)二Shell編程實(shí)驗(yàn)日期第12周周四3,4節(jié)教師評(píng)語(yǔ)實(shí)驗(yàn)成績(jī)指導(dǎo)教師1. 實(shí)驗(yàn)?zāi)康模?)學(xué)習(xí)和掌握vi編輯器的基本使用方法(2)學(xué)習(xí)和掌握編寫(xiě)簡(jiǎn)單的shell程序2. 實(shí)驗(yàn)內(nèi)容和步驟 (1)以root用戶(hù)身份登錄進(jìn)入Linux系統(tǒng) (2)啟動(dòng)vi,切換到輸入模式,輸入一段英文:Oh my god!No matter what