1<html lang="en"> 2<head> 3<title>rename - 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="remove.html#remove" title="remove"> 10<link rel="next" href="rewind.html#rewind" title="rewind"> 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="rename"></a> 29<p> 30Next: <a rel="next" accesskey="n" href="rewind.html#rewind">rewind</a>, 31Previous: <a rel="previous" accesskey="p" href="remove.html#remove">remove</a>, 32Up: <a rel="up" accesskey="u" href="Stdio.html#Stdio">Stdio</a> 33<hr> 34</div> 35 36<h3 class="section">4.52 <code>rename</code>—rename a file</h3> 37 38<p><a name="index-rename-260"></a><strong>Synopsis</strong> 39<pre class="example"> #include <stdio.h> 40 int rename(const char *<var>old</var>, const char *<var>new</var>); 41 42</pre> 43 <p><strong>Description</strong><br> 44Use <code>rename</code> to establish a new name (the string at <var>new</var>) for a 45file now known by the string at <var>old</var>. After a successful 46<code>rename</code>, the file is no longer accessible by the string at <var>old</var>. 47 48 <p>If <code>rename</code> fails, the file named <code>*</code><var>old</var> is unaffected. The 49conditions for failure depend on the host operating system. 50 51 <p><br> 52<strong>Returns</strong><br> 53The result is either <code>0</code> (when successful) or <code>-1</code> (when the file 54could not be renamed). 55 56 <p><br> 57<strong>Portability</strong><br> 58ANSI C requires <code>rename</code>, but only specifies that the result on 59failure be nonzero. The effects of using the name of an existing file 60as <code>*</code><var>new</var> may vary from one implementation to another. 61 62 <p>Supporting OS subroutines required: <code>link</code>, <code>unlink</code>, or <code>rename</code>. 63 64 <p><br> 65 66 </body></html> 67 68