// main.cpp
#include <iostream>
#include "Color.h"
#include <string>
#include "readFile.h"
using namespace std;
int main(void){
cout << RED << openReadf("Name.txt", true) << RESET << endl;
closeReadf();
return 0;
}
// feadFile.h
#include <iostream>
#include <fstream>
#include <string.h>
#include <stdio.h>
#include "Color.h"
//buffer static
static char buffer[100000] [100000];
//clear buffer
int closeReadf(){
memset(buffer, 0, sizeof(buffer));
return 0;
}
//method for reading files
std :: string openReadf(std :: string rFile,bool inText){
int i = 0;
std :: ifstream file;
std ::string inPut;
file.open(rFile);
if(file.is_open()){
while(!file.eof()){ // check for file existence
// buffer overflow check
if(sizeof(buffer) >= 100000){ std::cout << RED<<"FatalError: BUFFER OVERFLOW " << RESET << std:: endl;
closeReadf();
}
// file reading
file.getline(buffer[i],sizeof(buffer));
if (inText == true){ //output file content
inPut += buffer[i];
inPut += "\n";
}
i++;
}
}
else{
std :: cout << RED <<"FatalError: Not Found File 404" << RESET<< std :: endl;
std :: cin.get();
inPut == "";
}
file.close();
return inPut;
}
// Color.h
//Symbol color
#define RED "\033[1;31m"
#define BLUE "\033[0;34m"
#define RESET "\033[0m"
#define WHITE "\033[1;37m"
#define YELLOW "\033[0;33m"
#define GREEN "\033[0;32m"
#define BLACK "\033[0;30m"
//BackGraund
#define BGRESET "\033[40m"
#define BGRED "\033[41m"
#define BGGREEN "\033[42m"
#define BGBROWN "\033[43m"
#define BGBLUE "\033[44m"
-O3для максимальной оптимизации. – Arty Dec 24 '20 at 02:39while(!file.eof()){- наверное, пора стандарт переписывать, потому что сия ошибка просто вечная... – Harry Dec 24 '20 at 03:14