Syntax:
pos_type ofstream::tellp();
The tellp() function is used with output streams, and returns the current “put” position of the pointer in the stream. For example, the following code displays the file pointer as it writes to a stream:
string s("In Xanadu did Kubla Khan..."); ofstream fout("output.txt"); for( int i=0; i < s.length(); i++ ) { cout << "File pointer: " << fout.tellp(); fout.put( s[i] ); cout << " " << s[i] << endl; } fout.close();