Created
February 8, 2009 05:31
-
-
Save scooby/60208 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
int main(void) { | |
fstream foo1; | |
foo1.open("seek.bin", ios_base::in | ios_base::out | ios_base::binary | ios_base::trunc); | |
int i; | |
for(i = -100; i < 99; i ++) { | |
foo1.write((char*) &i, sizeof(int)); | |
} | |
foo1.flush(); | |
istream foo2(foo1.rdbuf()); | |
foo1.seekg(0, ios_base::beg); | |
foo2.seekg(100 * sizeof(int), ios_base::beg); | |
for(i = 0; i < 50; i++) { | |
int j, k; | |
foo1.read((char*) &j, sizeof(int)); | |
foo2.read((char*) &k, sizeof(int)); | |
cout << j << ", " << k << endl; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment