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

正文內容

教學計劃與預備知識(文件)

2025-10-13 18:01 上一頁面

下一頁面
 

【正文】 后改變模式。 – ifstream類支持磁盤文件輸入。 ifstream myFile。 ? ios類中的很多操縱符都可以應用于輸入流。 ? getline的功能是從輸入流中讀取多個字符,并且允許指定輸入終止字符,讀取完成后,從讀取的內容中刪除終止字符。 char name[23]。employee,sizeof(employee))。 } else { cout ERROR: Cannot open file 39。 ? tellg函數(shù)返回當前文件讀指針的位置。 if(tfile) { (8)。 } } else { cout ERROR: Cannot open file 39。 ifstream tfile(payroll,ios::binary | ios::nocreate)。 39。. endl。 4. 輸入 /輸出流 include include include undef NDEBUG // Make sure assert works. void main() { fstream stream(“,ios::in | ios::out | ios::binary)。 cout Get pointer is hex () endl。temp 256。 cout \nNow setting the put pointer to hex 50 endl。 cout \nNow setting the get pointer to hex 40 endl。 cout \nNow writing one character endl。 cout Get pointer is hex () endl。 cout Get pointer is hex () endl。 short long ? 數(shù)組 ? 一維、二維、多維 ? 按行排列(行優(yōu)先) [與FORTRAN不同 ] ? 下標從 0開始 [與 FORTRAN不同 ] ? 理解: A, A[0], amp。a[0][10]。 struct person *next。 char sex。 運算符 ? 算術運算: + * / ++ % ? 關系運算: , , =, =, ==, != ? 邏輯運算: amp。a, *a, ab, ? 注意: i++, ++i的區(qū)別 控制語句 ? 單語句與復合語句 ? 條件控制 ? ifelse, ifelse if……else ? switchcasedefault ? 循環(huán)控制 ? for (已經(jīng)知道循環(huán)次數(shù)) ? While (先知結束條件) ? dowhile(后知結束條件) ? 其它控制 ? break, continue, goto, return, exit (1) while ((ch=getchar()) != ?\n?)。 c = a+b。 while (a != 1) { b += a。 do { b += a。 i 10。 a++。 if (!fp) { printf(“can?t open file: \n”)。 if (!fp1) { ……} fread(amp。buffer[600], sizeof(float), 10, fp2)。a。a[0]。 pa = a。 struct xp *next。 pxpnext = (struct xp *)malloc(sizeof(struct xp))。 pxpx = ?b?。 i++) a[i] = (char *)malloc(16*sizeof(char))。 ?數(shù)組指針 int b[10][4], (*a)[4]。 func2(amp。 i++。 } 。 *i += 10。j)。 i = j = 1。 strcpy(a[1], “”)。 for ( i = 0。 pxpnextx = ?x?。 Struct xp axp[10], *pxp。 /* a[2][1] = */ ?指向結構的指針 struct xp { char x。 *(pa+1) = 。 float a[100], *pa。 …… 指針 ? 指向變量的指針 ? 指向數(shù)組的指針 ? 指向結構的指針 ? 指針數(shù)組 ? 數(shù)組指針 ? 函數(shù)指針 float a, *pa。 fclose(fp1) fp2 = fopen(“”, “wb”)。 float buffer[1024]。 fwrite(buffer, size, count, stream) FILE *fp。 j 10。 (5) a = 0。 (4) a = 1。 } (3) a = 1。 a = 1。, || ? 位運算: amp。 } Person。 ? typedef定義類型 typedef int INTEGER typedef float REAL REAL a, b。 Sizeof(int) Sizeof(short) Sizeof(float) Sizeof(double) Sizeof(char) 類型與定義 ? 結構 struct person { char name[20]。 int b, *pa。 ()。 cout \nNow reading one character endl。a39。 cout Get pointer is hex () endl。 cout Get pointer is hex () endl。 } cout Get pointer is hex () endl。 cout Now writing 256 bytes... endl。 char input。 兩個重要的 I/O流類都是從 iostream派生的:fstream, strstream ? fstream類支持文件的 I/O,構造 fstream對象可以對文件進行讀、寫。 } } else { cout ERROR: Cannot open file 39。 (ch)。. endl。 if (!ch) break。 輸入流成員函數(shù) 例 7 設置位置指針 include void main() { char ch。. endl。 39。 ifstream is(payroll,ios::binary |ios::nocreate)。 如果給出長度參數(shù),當遇到文件結束或者在文本模式文件中遇到文件結束標記字符時結束讀取。 輸入流成員函數(shù) ? open函數(shù)把該流與一個特定磁盤文件相關聯(lián)。 //打開文件 filename 提取運算符( ) ? 提取運算符 ()對于所有標準 C++數(shù)據(jù)類型都是預先設計好的。 ifstream myFile(filename,iosmode)。 3. 輸入流 ? 重要的輸入流類: – istream類最適合用于順序文本模式輸入。 ((char *) amp。 ? close函數(shù) 關閉與一個輸出文件流關聯(lián)的磁盤文件 ? 錯誤處理函數(shù) 在寫到一個流時進行錯誤處理 輸出文件流成員函數(shù) 例 5 向文件輸出 include struct Date { int mo,da,yr。 輸出文件流成員函數(shù) ? seekp和 tellp函數(shù) 操作文件流的內部指針 ostreamamp。 ? put函數(shù) 把一個字符寫到輸出流中 ostreamamp。 –執(zhí)行非格式化寫操作的成員函數(shù)。i4。 } 輸出結果如下 : Zoot Jimmy Al Stan 例 4 控制輸出精度 include include void main() { double values[ ] = {,}。 char *names[ ] = {Zoot, Jimmy, Al, Stan}。 for (int i=0。 cout values[i] 39。 i++) { (10)。\n39。 for(int i=0。 // Unbuffered mode 輸出流對象 插入運算符( ) ? 插入 ()運算符是所有標準 C++數(shù)據(jù)類型預先設計的。 //打開文件 , 使流對象與文件建立聯(lián)系 輸出流對象 ? 在一個由文件指示符標識的打開文件基礎上構造一個 ofstream對象。 輸出流對象 ? 可以在調用缺省構造函數(shù)之后使用 open成員函數(shù)打開文件 ofstream myFile。 – clog 類似于 cerr,但是有緩沖,緩沖區(qū)滿時被輸出。 ? 程序建立一個 流對象 ,并指定這個流對象與某個文件對象建立連接,程序操作流對象,流對象通過文件系統(tǒng)對所連接的文件對象產(chǎn)生作用。 6) 文件可按字節(jié),字符串,數(shù)據(jù)塊為單位讀寫,文件也可按指定的格式進行讀寫。 2) C文件按編碼方式分為二進制文件和 ASCII文件。 } } 6. 文件的操作錯誤檢查 前面介紹了有關的文件操作函數(shù),這些函數(shù)本身有返回值,通過它們的返回值可以發(fā)現(xiàn)文件操作錯誤。 /* Move the pointer 20 bytes ahead: */ fseek(fp, 20L, SEEK_CUR)。 char list[100]。 printf( The values read are: %d and %d\n, d1, d2 )。 rewind(fp)。 //從當前位置向前移動 10字節(jié) 起始點 名稱 用數(shù)字代表 文件開始 SEEK_SET 0 文件當前位置 SEEK_CUR 1 文件末尾 SEEK_END 2 include void main( void ) { FILE *fp。 fseek一般用于二進制文件,其中: a) “ 文件指針 ” 指向被移動的文件; b) “ 位移量 ” 表示移動的字節(jié)數(shù) , 要求位移量是 long型數(shù)據(jù) ,以便在文件長度大于 64KB 時不會出錯 。 fseek(文件指針 , 位移量 , 起始點 )。但在實際問題中常要求只讀寫文件中某一指定的部分。t, str)。 FILE *fp。 fclose(fp)。 int t = 32768。b, str)。 其有關的格式說明請參閱: scanf/printf中的格式說明 。 4) 數(shù)據(jù)格式化讀寫函數(shù) fscanf和 fprintf fscanf/fprintf函數(shù)與前面使用的 scanf/printf和 sscanf/sprintf函數(shù)的功能相似 , 都是格式化讀寫函數(shù) 。 printf(“%s%f%s\n”, , , == 0 ? “男” : “女
點擊復制文檔內容
電大資料相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1