filetobuf.h

来自「html文件编码转换与解析」· C头文件 代码 · 共 42 行

H
42
字号
#include<iostream>#include<string.h>#include<stdlib.h>#include<fstream>#include<locale>using namespace std;char buf[5][1024]; //bufferint flag = 0; //bufferflagfstream fis; //input file fstream  fstream fanchor; //output anchor text and url file fstreamfstream ftext; //output title and text file fsteam//read file initializationint initread(char *filename) {	fis.open(filename, ios::in);//	cout<<"The file:"<< filename <<endl;//	cout<<sizeof(buf[flag])<<endl;	return 0;}//read file's content into the bufferint readbuf() {	int readnum;	if (fis.read(buf[flag], sizeof(buf[flag]))) {		//		cout << buf[flag];		flag = (flag +1) % 5;	//	cout<<"change to buf: "<< flag <<endl;		return 0;	} else {		readnum = fis.gcount();		buf[flag][readnum]= '\0';		//		cout<<buf[flag]<<endl;		return 1;	}}//Reading end, close the filestreamvoid ReadEnd() {	fis.close();}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?