#include <fstream>
#include <string>
#include <iostream>
using namespace std;
int main() {
fstream inout( "invoice.dat", ios::in | ios::out );
inout << 1234 << " " << 56.78 << " " << "apples" << '\n';
cout<< inout.tellg()<< endl;
cout << inout.tellp() << endl;
inout.seekg( 0 );
cout << inout.tellg() << endl;
cout << inout.tellp() << endl;
int x = 0;
double y = 0.0;
string z = " ";
inout >> x;
inout.seekg( 8, ios::cur );
inout >> z;
cout << x << " " << y << " " << z << endl;
return 0;
}
|