#include <fstream.h>#include <stdio.h>
//using namespace std;void readf(fstream f,char* fd);void writef(fstream f,char* fd);
void main(){ fstream outfile; char filedirection[20] = "f1.dat"; //readf(outfile,filedirection); writef(outfile,filedirection);}
void readf(fstream f,char* fd){ //f.open("f1.dat",ios::out|ios::app); f.open(fd,ios::out); if (!f) { cerr<<"open f error!"<<endl; //exit(1); }
//char a[100] = "LiuQiang is a so good man!\nQiangLiu is a very good man!"; double a[10]; for (int i=0;i<10;i++) { a[i] = 123.678; } for (i=0;i<10;i++) { f<<a[i]<<endl; } f.close();}
void writef(fstream f,char* fd){ f.open(fd,ios::in); char b[10][10]; for (int i=0;i<10;i++) { f>>b[i]; } for (i =0;i<10;i++) { cout<<b[i]<<endl; } cout<<endl; f.close();} |