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

正文內(nèi)容

第13章文件(文件)

2025-08-08 23:40 上一頁面

下一頁面
 

【正文】 length。 else { fseek(fp,0L,SEEK_END)。 } } 例 求文件長度 () 167。 if (ferror(stream)) { printf(Error reading from \n)。 return 0。 } if(!ferror(stream)) printf(Error indicator cleared!)。 stream = fopen(, w)。 printf(Length of File is %1d bytes\n,length)。 fp=fopen(filename,rb)。 include main() { FILE *fp。 char name[10]。stud[i],sizeof(struct student_type),1,fp)。 } for(i=0。 FILE *fp。 } ?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)。 rewind(fp1)。 文件的定位 ?幾個概念 ?文件位置指針 指向當(dāng)前讀寫位置的指針 ?讀寫方式 ?順序讀寫:位置指針按字節(jié)位置順序移動,叫 ~ ?隨機讀寫:位置指針按需要移動到任意位置,叫 ~ ?rewind函數(shù) ?函數(shù)原型: void rewind(FILE *fp) ?功能:重置文件位置指針到文件開頭 ?返值:無 例 對一個磁盤文件進行顯示和復(fù)制兩次操作 include main() { FILE *fp1,*fp2。exit(0)。 fputs(\n,fp)。 if((fp=fopen(,w))==NULL) { printf(cann39。/*read from file*/ fprintf(stdout,%s %d,c,b)。t open file)。a)。 if((fp=fopen(test,w))==NULL) { puts(can39。t)。 } ?格式化 I/O:fprintf與 fscanf ?函數(shù)原型: int fprintf(FILE *fp,const char *format[,argument,…]) int fscanf(FILE *fp,const char *format[,address,…]) ?功能:按格式對文件進行 I/O操作 ?返值:成功 ,返回 I/O的個數(shù) 。i++) { fread(amp。 if((fp=fopen(d:\\fengyi\\exe\\stu_dat,rb))==NULL) { printf(cannot open file\n)。stud[i],sizeof(struct student_type),1,fp)!=1) printf(file write error\n)。 return。 display()。i++) scanf(%s%d%d%s,stud[i].name,amp。 }stud[SIZE]。 例 從鍵盤輸入 4個學(xué)生數(shù)據(jù),把他們轉(zhuǎn)存到磁盤文件中去 include define SIZE 2 struct student_type { char name[10]。 for(i=0。 char sex。i++) fread(amp。 fp=fopen(“”,“rb”)。 fclose(out)。 } if ((out = fopen(outfile, w))== NULL) { printf(Cannot open outfile.\n)。 scanf(%s,infile)。 fclose(in)。 exit(0)。 char ch。 } while((ch=fgetc(fp))!=EOF) putchar(ch
點擊復(fù)制文檔內(nèi)容
試題試卷相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1