用C++实现FILE的读写

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
#define liujunchang return
#define code 0
#define codes -1
namespace File{
	int OutAndReadFileVoid(const char *FileNames ,const int Void) {
		if(Void==-1) {
			MessageBox(NULL,"Error:\n	Void Error\n	Error Code:E1","OutAndReadFileVoid",MB_OK|MB_ICONHAND);
			fclose(stdout);
			freopen("Errors.txt","a",stdout) ;{
				time_t timep;
				time(&timep);
				printf("%s", ctime(&timep));
				cout<<"Error:\n	Void Error\n	Error Code:E1\n";
				fclose(stdout);
			}
			system("start HelpTheOutAndReadFileVoid.helptxt");
			liujunchang codes;
		} else if(Void==0) {
			freopen(FileNames,"r",stdin);
			liujunchang code;
		} else if(Void==1) {
			freopen(FileNames,"w",stdout);
			liujunchang code;
		} else if(Void==2) {
			freopen(FileNames,"a",stdout);
			freopen(FileNames,"a",stdin);
			liujunchang code;
		} else if(Void==3) {
			freopen(FileNames,"w+",stdout);
			freopen(FileNames,"w+",stdin);
			liujunchang code;
		} else if(Void==4) {
			freopen(FileNames,"r+",stdin);
			freopen(FileNames,"r+",stdout);
			liujunchang code;
		} else if(Void==5) {
			freopen(FileNames,"a+",stdin);
			freopen(FileNames,"a+",stdout);
			liujunchang code;
		} else if(Void==6) {
			fclose(stdin);
			liujunchang code;
		} else if(Void==7) {
			fclose(stdout);
			liujunchang code;
		} else if(Void==8) {
			fclose(stdin);
			fclose(stdout);
			liujunchang code;
		}else {
			MessageBox(NULL,"Error:\n	Void Error\n	Error Code:E1","OutAndReadFileVoid",MB_OK|MB_ICONHAND);
			fclose(stdout);
			freopen("Errors.txt","a",stdout) ;{
				time_t timep;
				time(&timep);
				printf("%s", ctime(&timep));
				cout<<"Error:\n	Void Error\n	Error Code:E1\n";
				fclose(stdout);
			}
			system("start HelpTheOutAndReadFileVoid.helptxt");
			liujunchang codes;
		}
		liujunchang code;
	}
}
using namespace File;
int main(int argc,char **argv) {
// TEST	
//	OutAndReadFileVoid("OutAndReadFileVoid.trytxt",-1);
//	printf("OK,the Void is Running");
//	OutAndReadFileVoid("OutAndReadFileVoid.trytxt",-1);
	char *InFileName=new char[10000];
	cout<<"In the Filenames:";
	cin>>InFileName;	
	int Voids;
	cout<<"In the Voids(0-8):";
	cin>>Voids;	
	cout<<"In The File:";
	OutAndReadFileVoid(InFileName,Voids);
	char File;
	do
	{
		File=getchar();
		if(File!=EOF)
			cout<<File;
	}
	while(File!=EOF);
	liujunchang code;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值