• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2013.11/share/doc/arm-arm-none-eabi/html/libc/
1<html lang="en">
2<head>
3<title>freopen - 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="fread.html#fread" title="fread">
10<link rel="next" href="fseek.html#fseek" title="fseek">
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="freopen"></a>
29<p>
30Next:&nbsp;<a rel="next" accesskey="n" href="fseek.html#fseek">fseek</a>,
31Previous:&nbsp;<a rel="previous" accesskey="p" href="fread.html#fread">fread</a>,
32Up:&nbsp;<a rel="up" accesskey="u" href="Stdio.html#Stdio">Stdio</a>
33<hr>
34</div>
35
36<h3 class="section">4.25 <code>freopen</code>&mdash;open a file using an existing file descriptor</h3>
37
38<p><a name="index-freopen-196"></a><a name="index-g_t_005ffreopen_005fr-197"></a><strong>Synopsis</strong>
39<pre class="example">     #include &lt;stdio.h&gt;
40     FILE *freopen(const char *<var>file</var>, const char *<var>mode</var>,
41         FILE *<var>fp</var>);
42     FILE *_freopen_r(struct _reent *<var>ptr</var>, const char *<var>file</var>,
43         const char *<var>mode</var>, FILE *<var>fp</var>);
44     
45</pre>
46   <p><strong>Description</strong><br>
47Use this variant of <code>fopen</code> if you wish to specify a particular file
48descriptor <var>fp</var> (notably <code>stdin</code>, <code>stdout</code>, or <code>stderr</code>) for
49the file.
50
51   <p>If <var>fp</var> was associated with another file or stream, <code>freopen</code>
52closes that other file or stream (but ignores any errors while closing
53it).
54
55   <p><var>file</var> and <var>mode</var> are used just as in <code>fopen</code>.
56
57   <p>If <var>file</var> is <code>NULL</code>, the underlying stream is modified rather than
58closed.  The file cannot be given a more permissive access mode (for
59example, a <var>mode</var> of "w" will fail on a read-only file descriptor),
60but can change status such as append or binary mode.  If modification
61is not possible, failure occurs.
62
63   <p><br>
64<strong>Returns</strong><br>
65If successful, the result is the same as the argument <var>fp</var>.  If the
66file cannot be opened as specified, the result is <code>NULL</code>.
67
68   <p><br>
69<strong>Portability</strong><br>
70ANSI C requires <code>freopen</code>.
71
72   <p>Supporting OS subroutines required: <code>close</code>, <code>fstat</code>, <code>isatty</code>,
73<code>lseek</code>, <code>open</code>, <code>read</code>, <code>sbrk</code>, <code>write</code>.
74
75   <p><br>
76
77   </body></html>
78
79