D
D
Daniel2018-10-17 21:48:40
C++ / C#
Daniel, 2018-10-17 21:48:40

How to find file size in c++?

I use the most popular code in the Internet that I found, as a result, an array is created larger than the file itself, at the end after the end of the text representation of the file, a line of hieroglyphs is added

std::fstream file1("C:\\\\Users\\fdfgdfgdfgii\\Desktop\\sait\\index.html", std::fstream::in);
  if (file1.is_open() == false) throw "EROR ";
     file1.seekp(0, std::ios::end);
     int size=file1.tellp();
     char *bfile = new char[size];
     file1.seekp(0, std::ios::beg);
     file1.read(bfile, size);// получается буффер больше чем сам файл, предполагаю что там свойства файла


    c->sendHttp(bfile, size);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question