This is the loop I have for reading from a file of any size, and writing to a 1016 byte char* packet 1016 bytes each time then sending it (sending not included yet).
Is the seekg() necessary? Or does reading move the pointer to the front of the next chunk already?
ifstream file (packet.message, ios::in|ios::binary|ios::ate);
if(file.is_open()) {
size = file.tellg();
file.seekg(0, ios::beg);
for(int i = 0; !ios::eof; i++) {
memset(packet.message,0,1016*sizeof(char));
file.read(packet.message,1016*sizeof(char));
file.seekg(i*1016*sizeof(char));
}
}
I know this isn't an issue for writing to a file, since you just keep writing to the end until the file is the right size.
Edit: added the whole bit of code in the if statement.