Hello, I am trying to make a program that sends a file from one computer to another, as a project for myself. The below code works fine for text files, but for some reason, doesn't read the entire file if it is a binary.
sendfile.seekg (0, sendfile.end);
int flen = sendfile.tellg();
Here it is: ifstream sendfile(filepath.c_str(), ios::binary);
flen is an integer that finds the length of the file. It works fine. The erase part of the code is used as a fix for another bug, but is not important here.
I used this:
int bytesread = sendfile.gcount();
bool testfail = sendfile.fail();
and it showed nothing wrong. Bytesread showed the correct number of bytes, and it did not fail.