Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void run1()
- {
- size_t buffer_size = 1<<20;
- char *buffer = new char[buffer_size];
- string fileName;
- getline(cin,fileName);
- std::ifstream fin(fileName);
- while (fin)
- {
- // Try to read next chunk of data
- fin.read(buffer, buffer_size);
- // Get the number of bytes actually read
- size_t count = fin.gcount();
- // If nothing has been read, break
- cout << buffer;
- if (!count)
- break;
- // Do whatever you need with first count bytes in the buffer
- // ...
- }
- delete[] buffer;
- }
Advertisement
Add Comment
Please, Sign In to add comment