文件读写

 1 #include<fstream>
 2 #include<iostream>
 3 #include<stdlib.h>
 4 using namespace std;
 5 int main()
 6 {
 7     int a[10];
 8     ofstream outfile("e://out_put_file.txt",ios::out);
 9     if(!outfile)
10     {
11         cerr<<"open error !"<<endl;
12         exit(1);
13     }
14     cout<<"enter 10 integer numbers :"<<endl;
15     for(int i=0;i<10;i++)
16     {
17         cin>>a[i];
18         outfile<<a[i]<<" ";
19     }
20     outfile.close();
21     return 0;
22 }

 

posted @ 2016-05-23 17:04  X-POWER  阅读(235)  评论(0编辑  收藏  举报