| <html lang="en"> |
| <head> |
| <title>fgetpos - Untitled</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="Untitled"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Stdio.html#Stdio" title="Stdio"> |
| <link rel="prev" href="fgetc.html#fgetc" title="fgetc"> |
| <link rel="next" href="fgets.html#fgets" title="fgets"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="fgetpos"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="fgets.html#fgets">fgets</a>, |
| Previous: <a rel="previous" accesskey="p" href="fgetc.html#fgetc">fgetc</a>, |
| Up: <a rel="up" accesskey="u" href="Stdio.html#Stdio">Stdio</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">4.11 <code>fgetpos</code>—record position in a stream or file</h3> |
| |
| <p><a name="index-fgetpos-166"></a><a name="index-g_t_005ffgetpos_005fr-167"></a><strong>Synopsis</strong> |
| <pre class="example"> #include <stdio.h> |
| int fgetpos(FILE *<var>fp</var>, fpos_t *<var>pos</var>); |
| int _fgetpos_r(struct _reent *<var>ptr</var>, FILE *<var>fp</var>, fpos_t *<var>pos</var>); |
| |
| </pre> |
| <p><strong>Description</strong><br> |
| Objects of type <code>FILE</code> can have a “position” that records how much |
| of the file your program has already read. Many of the <code>stdio</code> functions |
| depend on this position, and many change it as a side effect. |
| |
| <p>You can use <code>fgetpos</code> to report on the current position for a file |
| identified by <var>fp</var>; <code>fgetpos</code> will write a value |
| representing that position at <code>*</code><var>pos</var>. Later, you can |
| use this value with <code>fsetpos</code> to return the file to this |
| position. |
| |
| <p>In the current implementation, <code>fgetpos</code> simply uses a character |
| count to represent the file position; this is the same number that |
| would be returned by <code>ftell</code>. |
| |
| <p><br> |
| <strong>Returns</strong><br> |
| <code>fgetpos</code> returns <code>0</code> when successful. If <code>fgetpos</code> fails, the |
| result is <code>1</code>. Failure occurs on streams that do not support |
| positioning; the global <code>errno</code> indicates this condition with the |
| value <code>ESPIPE</code>. |
| |
| <p><br> |
| <strong>Portability</strong><br> |
| <code>fgetpos</code> is required by the ANSI C standard, but the meaning of the |
| value it records is not specified beyond requiring that it be |
| acceptable as an argument to <code>fsetpos</code>. In particular, other |
| conforming C implementations may return a different result from |
| <code>ftell</code> than what <code>fgetpos</code> writes at <code>*</code><var>pos</var>. |
| |
| <p>No supporting OS subroutines are required. |
| |
| <p><br> |
| |
| </body></html> |
| |