?? 714.cpp
字號:
//714.CPP
//demo fstream 先向文件寫一個整型數組,然后讀出
#include <iostream.H>
#include <fstream.H>
main(void)
{
int n[5]={1,2,3,4,5};
int i;
ofstream outFile("714.dat");
if(!outFile)
{
cout << "Cannot open file";
return 1;
}
outFile.write((unsigned char*)&n,sizeof n);
outFile.close();
for(i=0;i<5;i++) n[i]=0; //clear array
ifstream inFile("714.dat");
inFile.read((unsigned char *)&n,sizeof n);
for(i=0;i<5;i++) //show values read from file
cout << n[i] << " ";
cout << endl;
inFile.close();
return 0;
}
/*
1 2 3 4 5
*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -