1<html lang="en"> 2<head> 3<title>fgetpos - Untitled</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Untitled"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Stdio.html#Stdio" title="Stdio"> 9<link rel="prev" href="fgetc.html#fgetc" title="fgetc"> 10<link rel="next" href="fgets.html#fgets" title="fgets"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<meta http-equiv="Content-Style-Type" content="text/css"> 13<style type="text/css"><!-- 14 pre.display { font-family:inherit } 15 pre.format { font-family:inherit } 16 pre.smalldisplay { font-family:inherit; font-size:smaller } 17 pre.smallformat { font-family:inherit; font-size:smaller } 18 pre.smallexample { font-size:smaller } 19 pre.smalllisp { font-size:smaller } 20 span.sc { font-variant:small-caps } 21 span.roman { font-family:serif; font-weight:normal; } 22 span.sansserif { font-family:sans-serif; font-weight:normal; } 23--></style> 24<link rel="stylesheet" type="text/css" href="../cs.css"> 25</head> 26<body> 27<div class="node"> 28<a name="fgetpos"></a> 29<p> 30Next: <a rel="next" accesskey="n" href="fgets.html#fgets">fgets</a>, 31Previous: <a rel="previous" accesskey="p" href="fgetc.html#fgetc">fgetc</a>, 32Up: <a rel="up" accesskey="u" href="Stdio.html#Stdio">Stdio</a> 33<hr> 34</div> 35 36<h3 class="section">4.11 <code>fgetpos</code>—record position in a stream or file</h3> 37 38<p><a name="index-fgetpos-166"></a><a name="index-g_t_005ffgetpos_005fr-167"></a><strong>Synopsis</strong> 39<pre class="example"> #include <stdio.h> 40 int fgetpos(FILE *<var>fp</var>, fpos_t *<var>pos</var>); 41 int _fgetpos_r(struct _reent *<var>ptr</var>, FILE *<var>fp</var>, fpos_t *<var>pos</var>); 42 43</pre> 44 <p><strong>Description</strong><br> 45Objects of type <code>FILE</code> can have a “position” that records how much 46of the file your program has already read. Many of the <code>stdio</code> functions 47depend on this position, and many change it as a side effect. 48 49 <p>You can use <code>fgetpos</code> to report on the current position for a file 50identified by <var>fp</var>; <code>fgetpos</code> will write a value 51representing that position at <code>*</code><var>pos</var>. Later, you can 52use this value with <code>fsetpos</code> to return the file to this 53position. 54 55 <p>In the current implementation, <code>fgetpos</code> simply uses a character 56count to represent the file position; this is the same number that 57would be returned by <code>ftell</code>. 58 59 <p><br> 60<strong>Returns</strong><br> 61<code>fgetpos</code> returns <code>0</code> when successful. If <code>fgetpos</code> fails, the 62result is <code>1</code>. Failure occurs on streams that do not support 63positioning; the global <code>errno</code> indicates this condition with the 64value <code>ESPIPE</code>. 65 66 <p><br> 67<strong>Portability</strong><br> 68<code>fgetpos</code> is required by the ANSI C standard, but the meaning of the 69value it records is not specified beyond requiring that it be 70acceptable as an argument to <code>fsetpos</code>. In particular, other 71conforming C implementations may return a different result from 72<code>ftell</code> than what <code>fgetpos</code> writes at <code>*</code><var>pos</var>. 73 74 <p>No supporting OS subroutines are required. 75 76 <p><br> 77 78 </body></html> 79 80