COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button
C++ LANGUAGE FILE POSITION POINTERS
File Position Pointers
Both istream and ostream provide member functions for
repositioning the file-position pointer. These member
functions are seekg ("seek get") for istream and seekp
("seek put") for ostream.
The argument to seekg and seekp normally is a long
integer. A second argument can be specified to indicate
the seek direction. The seek direction can be ios::beg
(the default) for positioning relative to the beginning
of a stream, ios::cur for positioning relative to the
current position in a stream or ios::end for positioning
relative to the end of a stream.
The file-position pointer is an integer value that
specifies the location in the file as a number of bytes
from the file's starting location. Some examples of
positioning the "get" file-position pointer are:
// position to the nth byte of fileObject (assumes ios::beg)
fileObject.seekg( n );
// position n bytes forward in fileObject
fileObject.seekg( n, ios::cur );
// position n bytes back from end of fileObject
fileObject.seekg( n, ios::end );
// position at end of fileObject
fileObject.seekg( 0, ios::end );
No comments:
Post a Comment