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

正文內(nèi)容

第13章文件(參考版)

2024-08-01 23:40本頁面
  

【正文】 return 0。 } if(!ferror(stream)) printf(Error indicator cleared!)。 if (ferror(stream)) { printf(Error reading from \n)。 stream = fopen(, w)。 } } 例 求文件長度 () 167。 printf(Length of File is %1d bytes\n,length)。 else { fseek(fp,0L,SEEK_END)。 fp=fopen(filename,rb)。 long length。 include main() { FILE *fp。 char addr[15]。 char name[10]。 } fclose(fp)。stud[i],sizeof(struct student_type),1,fp)。i+=2) { fseek(fp,i*sizeof(struct student_type),0)。 } for(i=0。t open file\n)。 FILE *fp。 fseek(fp,10L,2)。 } ?fseek函數(shù) ?函數(shù)原型: int fseek(FILE *fp,long offset,int whence) ?功能:改變文件位置指針的位置 ?返值:成功,返回 0;失敗,返回非 0值 文件指針 位移量(以起始點為基點 ,移動的字節(jié)數(shù) ) 0 向后移動 0 向前移動 起始點 文件開始 SEEK_SET 0 文件當(dāng)前位置 SEEK_CUR 1 文件末尾 SEEK_END 2 例 fseek(fp,100L,0)。 fclose(fp1)。 rewind(fp1)。 fp2=fopen(d:\\fengyi\\bkc\\,w)。 文件的定位 ?幾個概念 ?文件位置指針 指向當(dāng)前讀寫位置的指針 ?讀寫方式 ?順序讀寫:位置指針按字節(jié)位置順序移動,叫 ~ ?隨機讀寫:位置指針按需要移動到任意位置,叫 ~ ?rewind函數(shù) ?函數(shù)原型: void rewind(FILE *fp) ?功能:重置文件位置指針到文件開頭 ?返值:無 例 對一個磁盤文件進行顯示和復(fù)制兩次操作 include main() { FILE *fp1,*fp2。 fclose(fp)。exit(0)。 if((fp=fopen(,r))==NULL) { printf(cann39。 fputs(\n,fp)。exit(0)。 if((fp=fopen(,w))==NULL) { printf(cann39。 } ?字符串 I/O: fgets與 fputs ?函數(shù)原型: char *fgets(char *s,int n,FILE *fp) int fputs(char *s,FILE *fp) ?功能:從 fp指向的文件讀 /寫一個字符串 ?返值: ?fgets正常時返回讀取字符串的首地址;出錯或文件尾,返回NULL ?fputs正常時返回寫入的最后一個字符;出錯為 EOF 例 從鍵盤讀入字符串存入文件,再從文件讀回顯示 fgets從 fp所指文件讀 n1個字符送入 s指向的內(nèi)存區(qū) , 并在最后加一個 ‘ \0’ (若讀入 n1個字符前遇換行符或文件尾( EOF) 即結(jié)束 ) fputs把 s指向的字符串寫入 fp指向的文件 include main() { FILE *fp。/*read from file*/ fprintf(stdout,%s %d,c,b)。 } fscanf(fp,%s%d,c,amp。t open file)。/*write to file*/ fclose(fp)。a)。 exit() 。 if((fp=fopen(test,w))==NULL) { puts(can39。 int a,b。t)。 //將 i和 t按 %d,% fp文件 fscanf(fp,“%d,%f”,amp。 } ?格式化 I/O:fprintf與 fscanf ?函數(shù)原型: int fprintf(FILE *fp,const
點擊復(fù)制文檔內(nèi)容
試題試卷相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1