?? 11-4-4-1.cpp
字號:
#include <iostream.h>
#include <fstream.h>
void main()
{ fstream f("MYDATA", ios::in|ios::out|ios::binary);
for(int i=0; i < 10; i ++) // 寫10個整數
f.write((char *)&i, sizeof(int));
streampos pos=f.tellp(); // 記下當前位置
for(i=10; i < 20; i ++) // 寫10個整數
f.write((char *)&i, sizeof(int));
f.seekg(pos); // 將讀指針定位到pos位置
f.read((char *)&i, sizeof(int));
cout << "The Data is:" << i << endl;
f.seekp(0, ios::beg);
for(i=100; i < 120; i ++) // 開頭位置重寫20個整數
f.write((char *)&i, sizeof(int));
f.seekg(pos); // 將讀指針定位到pos位置
f.read((char *)&i, sizeof(int));
cout << "The Data is:" << i << endl;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -