Changeset 1060 in Sophya for trunk/Eval/COS
- Timestamp:
- Jul 11, 2000, 1:00:11 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Eval/COS/tios.cc
r1055 r1060 6 6 7 7 void tread(istream* s); 8 void tread2(istream* s); 8 9 void twrite(ostream* s); 9 10 … … 11 12 { 12 13 if (narg < 2) { 13 cout << "Usage: tios r/w" << endl; 14 cout << "Usage: tios w/r/r2 \n" 15 << " w : Write data file tios.cc \n" 16 << " r : Read data file with seekg(ios::end) -> Linux Pb \n" 17 << " r2 : Read data file with seekg(ios::beg) Linux OK (??) \n" << endl; 14 18 exit(0); 15 19 } … … 20 24 // is = new ifstream("tios.dat", ios::in | ios::binary); 21 25 is = new ifstream("tios.dat", ios::in ); 22 tread(is); 26 if ( arg[1][1] == '2') tread2(is); 27 else tread(is); 23 28 delete is; 24 29 } … … 65 70 } 66 71 72 cout << " ----- Check Output from here ------- " << endl; 67 73 s->seekg(-(sizeof(int)+sizeof(float)+sizeof(double)), ios::end); 68 74 pos = s->tellg(); … … 84 90 } 85 91 92 void tread2(istream* s) 93 { 94 int i; 95 int iv; 96 float fv; 97 double dv; 98 long pos; 99 for(i=0; i<7; i++) { 100 pos = s->tellg(); 101 s->read((char *)(&iv), sizeof(int)); 102 s->read((char *)(&fv), sizeof(float)); 103 s->read((char *)(&dv), sizeof(double)); 104 cout << "tread2 " << i << " IV= " << iv << " FV= " << fv << " DV= " << dv 105 << " Pos= " << pos << endl; 106 } 86 107 108 cout << " ----- Check Output from here ------- " << endl; 109 s->seekg(0, ios::end); 110 pos = s->tellg(); 111 cout << "Seek-tread2 s->seekg(0, ios::end); Pos = " << pos ; 112 pos -= (sizeof(int)+sizeof(float)+sizeof(double)); 113 cout << " ---> Pos= " << pos << endl; 114 s->seekg(pos, ios::beg); 115 pos = s->tellg(); 116 s->read((char *)(&iv), sizeof(int)); 117 s->read((char *)(&fv), sizeof(float)); 118 s->read((char *)(&dv), sizeof(double)); 119 i = 9; 120 cout << "Seek-tread2 " << i << " IV= " << iv << " FV= " << fv << " DV= " << dv 121 << " Pos= " << pos << endl; 122 123 124 s->seekg((sizeof(int)+sizeof(float)+sizeof(double)), ios::beg); 125 for(i=1; i<3; i++) { 126 pos = s->tellg(); 127 s->read((char *)(&iv), sizeof(int)); 128 s->read((char *)(&fv), sizeof(float)); 129 s->read((char *)(&dv), sizeof(double)); 130 131 cout << "Seek-tread2-2 " << i << " IV= " << iv << " FV= " << fv 132 << " DV= " << dv << " Pos= " << pos << endl; 133 } 134 }
Note:
See TracChangeset
for help on using the changeset viewer.