tellp [C++ Reference]
Keywords: io,tellp
Date: 2009-03-09T12:24:10-0700

## tellp

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();

Related Topics: seekg, seekp, tellg