Guest User

Untitled

a guest
Jun 6th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. void run1()
  2. {
  3. size_t buffer_size = 1<<20;
  4. char *buffer = new char[buffer_size];
  5. string fileName;
  6. getline(cin,fileName);
  7. std::ifstream fin(fileName);
  8.  
  9. while (fin)
  10. {
  11. // Try to read next chunk of data
  12. fin.read(buffer, buffer_size);
  13. // Get the number of bytes actually read
  14. size_t count = fin.gcount();
  15. // If nothing has been read, break
  16. cout << buffer;
  17. if (!count)
  18. break;
  19. // Do whatever you need with first count bytes in the buffer
  20. // ...
  21. }
  22.  
  23. delete[] buffer;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment