<s>
In	O
the	O
C++	B-Language
programming	I-Language
language	I-Language
,	O
seekg	B-Language
is	O
a	O
function	O
in	O
the	O
fstream	B-Language
library	O
(	O
part	O
of	O
the	O
standard	O
library	O
)	O
that	O
allows	O
you	O
to	O
seek	O
to	O
an	O
arbitrary	O
position	O
in	O
a	O
file	O
.	O
</s>
<s>
This	O
function	O
is	O
defined	O
for	O
ifstream	B-Language
class	O
-	O
for	O
ofstream	B-Language
class	O
there	O
's	O
a	O
similar	O
function	O
seekp	O
(	O
this	O
is	O
to	O
avoid	O
conflicts	O
in	O
case	O
of	O
classes	O
that	O
derive	O
both	O
istream	O
and	O
ostream	B-Language
,	O
such	O
as	O
iostream	O
)	O
.	O
</s>
<s>
position	O
is	O
the	O
new	O
position	O
in	O
the	O
stream	O
buffer	B-General_Concept
.	O
</s>
<s>
offset	O
is	O
an	O
integer	O
value	O
of	O
type	O
streamoff	O
representing	O
the	O
offset	O
in	O
the	O
stream	O
's	O
buffer	B-General_Concept
.	O
</s>
<s>
ios_base::beg	O
(	O
offset	O
from	O
the	O
beginning	O
of	O
the	O
stream	O
's	O
buffer	B-General_Concept
)	O
.	O
</s>
<s>
ios_base::cur	O
(	O
offset	O
from	O
the	O
current	O
position	O
in	O
the	O
stream	O
's	O
buffer	B-General_Concept
)	O
.	O
</s>
<s>
ios_base::end	O
(	O
offset	O
from	O
the	O
end	O
of	O
the	O
stream	O
's	O
buffer	B-General_Concept
)	O
.	O
</s>
<s>
Note	O
:	O
If	O
you	O
have	O
previously	O
got	O
an	O
end	O
of	O
file	O
on	O
the	O
stream	O
,	O
seekg	B-Language
will	O
not	O
reset	O
it	O
but	O
will	O
return	O
an	O
error	O
in	O
many	O
implementations	O
.	O
</s>
<s>
This	O
is	O
a	O
relatively	O
common	O
mistake	O
and	O
if	O
seekg( )	O
is	O
not	O
performing	O
as	O
expected	O
,	O
it	O
is	O
wise	O
to	O
clear	O
the	O
fail	O
bit	O
,	O
as	O
shown	O
below	O
.	O
</s>
