【正文】
inates. If it is found, the students name followedby : and his/her five marks are displayed (again, 1 must be shownas a space, as in ShowClass()). Let us assume that the student inquestion has marks 10,1,20,15,5Then the function displays a prompt to the user forthe first mark to leave the 1st mark 10 unchanged pressenterotherwise type the new mark and pressenter and reads the user39。sreply using gets() into a character arrays of size 80. Then it usessscanf() on that array to extract the response. Then the functiondisplays a prompt to the user for the second mark to leave the 2nd markunchanged pressenterotherwise type the new mark and pressenterand reads the user39。s reply using gets() into a character arrays of size 80.Then it uses sscanf() on that array to extract the response. Etc.for the third, fourth, and fifth.Note that both students and marks are passed to thisfunction by value,for this function does not need to modify the value stored in the pointer student.The same applies to marks.*/void EditMarks(char** students,int** marks){ int found, i, j。 char *name。 printf(Enter Student Name to be added marks in:\n)。 fflush(stdout)。 name = ReadLine()。 /* do we have the student yet ? */for(found = i = 0。 students[i] != NULL。 i++) { if (strcmp(students[i],name) == 0) { found = 1。 j=i。 break。 }}if (found) { printf(please input %s39。s marks of five classes divided with an 39。,39。\n,name)。 scanf(%d,%d,%d,%d,%d,amp。marks[j][0],amp。marks[j][1],amp。marks[j][2],amp。marks[j][3],amp。marks[j][4])。 return。}else {printf(wrong student name\n)。return。}}/*fuction readline*/char* ReadLine(){char *buf。int i, j, size。if ((buf = (char*) malloc(10)) == NULL) merror(0)。size = 10。j = 1。while(1) { for(i = 0。 i 10。 i++) { buf[++j] = getchar()。 if (buf[j] == 39。\n39。) { buf[j] = 39。\039。 break。 } }/*endfor*/ if (i == 10 amp。amp。 buf[j] != 39。\039。) { size += 10。 if ((buf = (char*) realloc((void*)buf,size)) == NULL) merror(1)。 continue。 } break。}/*endwhile*/return buf。}/*end ReadLine*/四、程序調(diào)試(說(shuō)明調(diào)試過(guò)程、問(wèn)題及其解決方法) 這個(gè)函數(shù)中 我采用scanf這個(gè)函數(shù)來(lái)讀取成績(jī),在讀取第五個(gè)成績(jī)的時(shí)候發(fā)現(xiàn)讀完后會(huì)在函數(shù)主菜單里出現(xiàn)一次的錯(cuò)誤 這時(shí)我上網(wǎng)查了資料 發(fā)現(xiàn)應(yīng)該在第五個(gè)輸入成績(jī)的時(shí)候在%s后面再加一個(gè)%c 來(lái)吃掉一個(gè)回車鍵 這樣主菜單就不會(huì)出現(xiàn)菜單錯(cuò)誤的情況 ,出現(xiàn)了很多失誤小錯(cuò)誤,不過(guò)后來(lái)在老師和同學(xué)的幫助下??戳藭?,最后都一一解決了。 五、總結(jié)1)從剛開始的概念模糊、知識(shí)點(diǎn)不清楚、無(wú)從下手開始到后來(lái)基本能實(shí)現(xiàn)功能,從本次編程實(shí)習(xí)中學(xué)會(huì)了很多知識(shí),編程過(guò)程中需要一個(gè)清晰的思路,一步一步慢慢實(shí)現(xiàn)功能,在寫代碼過(guò)程中要養(yǎng)成良好習(xí)慣,輸入法、代碼對(duì)齊、漏寫符號(hào)等一系列的問(wèn)題都是很值得注意的,另外要徹底知道各條語(yǔ)句的作用及函數(shù)的使用規(guī)則。2)編程過(guò)程中出現(xiàn)的最多問(wèn)題就是運(yùn)行時(shí)總是跳出警告框提示內(nèi)存什么的,出現(xiàn)這個(gè)問(wèn)題主要是寫代碼時(shí)候不嚴(yán)謹(jǐn),多處地方不能統(tǒng)一,導(dǎo)致機(jī)器運(yùn)行是容易出錯(cuò),避免這種問(wèn)題要仔細(xì)查看代碼任何一處地方,所有代碼都要遵守規(guī)則;3)在編寫過(guò)程中出現(xiàn)了很多問(wèn)題,現(xiàn)挑主要問(wèn)題說(shuō)明如下:調(diào)用函數(shù)是,子函數(shù)沒(méi)有形參,調(diào)用時(shí)卻添加了形參;定義變量時(shí)沒(méi)有注意類型,在輸入時(shí)錯(cuò)誤使用了輸入格式;一個(gè)子函數(shù)包含多一些語(yǔ)句時(shí),容易漏掉大括號(hào)導(dǎo)致程序檢查時(shí)主函數(shù)出現(xiàn)錯(cuò)誤;輸入的方法錯(cuò)誤導(dǎo)致運(yùn)行出錯(cuò);調(diào)用查找、修改函數(shù)不能進(jìn)入函數(shù)中,鏈表地址指向不對(duì),語(yǔ)句放置位子不對(duì);以上問(wèn)題在老師的指導(dǎo)下,一個(gè)一個(gè)解決了,同時(shí)也給自己加深了編寫程序要注意的地方。4)界面的美觀設(shè)計(jì)也是一個(gè)值得注意的問(wèn)題,對(duì)使用者是否能順利使用軟件至關(guān)重要,所以界面的設(shè)計(jì)很重要,好的提示以及規(guī)則能避免很多不必要的錯(cuò)誤。總結(jié):本次編程學(xué)習(xí)到了很多知識(shí),特別感受到了鏈表在C語(yǔ)言中比數(shù)組來(lái)的更加方便,雖然完成了本次實(shí)習(xí)目的,但是設(shè)計(jì)出的軟件還有很大缺陷,不是很完善,在幾個(gè)地方不是很人性化,需要改進(jìn),比如在保存文件有累贅部分,有待完善。本次實(shí)習(xí)收獲很多,受益匪淺。