freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

《程序設(shè)計(jì)基礎(chǔ):c語言》1112ppt-文庫吧

2025-02-06 15:48 本頁面


【正文】 字符串字面值:” abcd”。編譯器會(huì)自動(dòng)在字面值“ abcd”最后加上’ \0?。 ? 字符數(shù)組: char str1[] = “abcd”。 ,編譯器會(huì)在字面值” abcd”最后加上’ \0? ? 字符數(shù)組: char str2[] ={?a?, ?b?, ?c?, ?d?, ?\0?}。,這種初始化方式要自己置’ \0?。 版權(quán)所有,復(fù)制注明出處 字符串處理 ?字符串處理函數(shù)大多數(shù)在 版權(quán)所有,復(fù)制注明出處 字符串處理 ?例 114 編一個(gè)函數(shù),從給定字符串(由形式參數(shù)給出)中去掉標(biāo)點(diǎn)符號(hào)(由形式參數(shù)給出)。 版權(quán)所有,復(fù)制注明出處 /*源文件: */ include include include include include define MAX_LENGTH 1000 、 char * erase(char *src, const char *set) { char *word。 char *tmpDest = malloc(strlen(src) + 1)。 tmpDest[0] = 39。\039。 assert(src)。 if(!set) return src。 word = strtok(src, set)。 字符串處理 版權(quán)所有,復(fù)制注明出處 while(NULL != word) { strcat(tmpDest, word)。 word = strtok(NULL, set)。 } strcpy(src, tmpDest)。 free(tmpDest)。 return src。 } int main(void) { char src[MAX_LENGTH] = This is an example, given by Wenbin.。 puts(src)。 erase(src, ,.)。 puts(src)。 system(PAUSE)。 return 0。 } 字符串處理 ?例 115 有 5個(gè)國家的名稱,存放在字符數(shù)組中,請(qǐng)編寫函數(shù)按從大到小的順序排列并輸出它們。 版權(quán)所有,復(fù)制注明出處 /*源文件: */ include include include include include define MAX_LENGTH 100 void sortCountry(char (*country)[MAX_LENGTH], int countryCount) { int i = 0。 int j = 0。 char *c = malloc(MAX_LENGTH + 1)。 assert(country)。 if(0 = countryCount || MAX_LENGTH = countryCount) { printf(國家數(shù)超過了處理的范圍 )。 return。 } 字符串處理 版權(quán)所有,復(fù)制注明出處 for(i = 0。 i countryCount 1。 i++) { for(j = 0。 j countryCount 1 i。 j++) { if(strcmp(country[j], country[j+1]) 0) { strcpy(c, country[j])。 strcpy(country[j], country[j+1])。 strcpy(country[j+1], c)。 } } } free(c)。 } 字符串處理 版權(quán)所有,復(fù)制注明出處 int main(void) { char country[][MAX_LENGTH] ={ Papua New Guinea, Albania, Colombia, Kyrgyzstan, China}。 int countryCount = 5。 int i = 0。 sortCountry(amp。country[0], countryCount)。 /*排序 */ for(i = 0。 i countryCount。 i++) puts(country[i])。 system(PAUSE)。 return 0。 } 版權(quán)所有,復(fù)制注明出處 本章授課內(nèi)容 標(biāo)準(zhǔn)語言補(bǔ)充 文件操作 字符串處理 字符處理 標(biāo)準(zhǔn)庫與非標(biāo)準(zhǔn)庫 文件 ?所謂“文件”一般是指存儲(chǔ)在外部介質(zhì)上數(shù)據(jù)的集合 ?基于數(shù)據(jù)流的概念, C語言提供了豐富的輸入 /輸出函數(shù) ? 文本流 ? 二進(jìn)制流 版權(quán)所有,復(fù)制注明出處 文件的打開與關(guān)閉 版權(quán)所有,復(fù)制注明出處 ?文件的打開與關(guān)閉函數(shù): 注意: 、雖然讀者可以利用 FILE 類型定義變量 ,但只有通過 fopen 生成的 FILE 類型的對(duì)象才是有意義的 文件的打開與關(guān)閉 ?例 116 設(shè)有 FILE *fp。,且 c 盤根目錄下存在 文件,文件內(nèi)容為“ This is an example.” 版權(quán)所有,復(fù)制注明出處 文件定位 ?標(biāo)準(zhǔn)庫提供了定位函數(shù)以幫助用戶實(shí)現(xiàn)對(duì)文件的隨機(jī)定位讀寫 ?C語言中的文件定位函數(shù): 版權(quán)所有,復(fù)制注明出處 文件定位 ?例 117 請(qǐng)?jiān)?c盤根目錄下建立一個(gè)名為 的文本文件,其內(nèi)容設(shè)置為: This ia an example, given by Wenbin.。 版權(quán)所有,復(fù)制注明出處 /*源文件: */ include include include include include define MAX_LENGTH 1000 int main(void) { FILE *fp = fopen(c:\\, r)。 long int pos。 char *str = malloc(MAX_LENGTH)。 assert(str)。 errno = 0。 if(!fp) { printf(stderr, open c:\ failed. Error code: %s\n, strerror(errno))。 return 1。 }
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1