Advertisement
Guest User

halluc1nati0n

a guest
Dec 8th, 2009
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <fstream>
  4. #include <iostream>
  5. #include <sstream>
  6. using namespace std;
  7.  
  8.  
  9. int main()
  10. {
  11.  
  12.     int fd, i, j, length, pos;
  13.     int k, bytes_read;
  14.     char buffer[100][16];
  15.     ifstream Read;
  16.     std::ostringstream oss;
  17.     int current_position = 0;
  18.     Read.open("from4to5", ios::binary);
  19.  
  20.     //Get the size of the file
  21.     Read.seekg(0, ios::end);
  22.     length = Read.tellg();
  23.     Read.seekg(0, ios::beg);
  24.  
  25.     for(i=0; i<length; i++)
  26.     {
  27.         buffer[i][16] = '\0';
  28.     }
  29.  
  30.  
  31.         //Read the file in 16byte segments or eof(), whichever comes first
  32.         //Testing the return condition of the function is preferred, as opposed to testing eof()
  33.  
  34.         while(Read.get(buffer[i], 17))
  35.         {
  36.             for(j=0; j<=16; j++)
  37.                 oss << buffer[i][j];
  38.             cout << "Contents : " << oss.str() << endl;
  39.             oss.seekp(0);
  40.             bytes_read = bytes_read + 16;
  41.             i++;
  42.         }
  43.         Read.clear();
  44.         Read.close();
  45.        
  46.        
  47.         sleep(15);
  48.        
  49.         Read.open("from4to5", ios::binary);
  50.         Read.seekg(bytes_read);
  51.  
  52.         while(Read.get(buffer[i], 17))
  53.         {
  54.             for(j=0; j<=16; j++)
  55.                 oss << buffer[i][j];
  56.             cout << "Contents : " << oss.str() << endl;
  57.             oss.seekp(0);
  58.             bytes_read = bytes_read + 16;
  59.             i++;
  60.         }
  61.    
  62.         Read.clear();
  63.         Read.close();
  64.  
  65.  
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement