Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(int argc, const char **argv ) {
- //MasterNew master;
- ifstream myfile;
- myfile.open ("C:\\Users\\G. Meier\\Documents\\myfile.txt", ios::in|ios::binary|ios::ate);
- int len = 3;
- char * memblock = new char [len + 1]; // allocate an extra byte for the null byte.
- myfile.seekg (0, ios::beg);
- myfile.read (memblock, len);
- // The magic fix :D
- memblock[len] = '\0';
- // Out put before turning it into a packet:
- cout << sizeof(memblock) << " " << memblock << endl;
- char * buffer = Packet::create(Packet::FILE, memblock);
- // Since the char * doesn't end with a null byte, tell the output stream to only show the first 8 bytes.
- // If we don't do this it'll just randomly output some data.
- cout.write(buffer, len + 5);
- return cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment