Advertisement
Guest User

Untitled

a guest
May 2nd, 2015
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. int main() {
  2.     int arr[5][2]={0,3,33,2,55,0,11,4,22,1};
  3.     ofstream fout ("data.txt",ios::binary);
  4.     fout.write((char*)arr,40);
  5.     fout.close();
  6.     int p = arr[0][1];
  7.     while (p) {
  8.         cout<<arr[p][0]<<endl;
  9.         p = arr[p][1];
  10.     };
  11.     cout<<endl;
  12.     ifstream fin ("data.txt",ios::binary);
  13.     fin.seekg(4);
  14.     fin.read((char*)&p,4);
  15.     while (p) {
  16.         fin.seekg(p*8);
  17.         fin.read((char*)&p,4);
  18.         cout<<p<<endl;
  19.         fin.read((char*)&p,4);
  20.     };
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement