Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <fcntl.h>
- #include <fstream>
- #include <iostream>
- using namespace std;
- int main()
- {
- int fd, i, oflag;
- char buf[100];
- ifstream Read;
- int current_position = 0;
- Read.open("from4to5", ios::binary);
- // The file has contents :
- // BD8d3700indiaC#EBD6d4700godgeD3EBD9d1311badge3TE
- while(!Read.eof()) {
- Read.get(buf, 17);
- cout << "child: # bytes read which were: " << buf << endl;
- };
- #
- //Save current position in file
- #
- current_position = Read.tellg();
- cout << current_position << endl;
- // seek to the position returned
- Read.seekg(current_position);
- // File is modified ..
- // Now, file has contents
- // BD8d3700indiaC#EBD6d4700godgeD3EBD9d1311badge3TEBD6d1210clerk41EBD2d1100mayor47E
- while(!Read.eof()) {
- Read.get(buf, 17);
- cout << "child: # bytes read which were: " << buf << endl;
- };
- Read.close();
- // Output is :
- // child: # bytes read which were: BD8d3700indiaC#E
- // child: # bytes read which were: BD6d4700godgeD3E
- // child: # bytes read which were: BD9d1311badge3TE
- // child: # bytes read which were: BD6d1210clerk41E
- // child: # bytes read which were: BD2d1100mayor47E
- // 80
- // But rather it was intended to be only
- // child: # bytes read which were: BD6d1210clerk41E
- // child: # bytes read which were: BD2d1100mayor47E
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement