📄 tmpnam.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>tmpnam</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="tmpnam"></a> <a name="tag_03_782"></a><!-- tmpnam --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_782_01"></a>NAME</h4><blockquote>tmpnam - create a name for a temporary file</blockquote><h4><a name="tag_03_782_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include <<a href="../basedefs/stdio.h.html">stdio.h</a>><br><br> char *tmpnam(char *</tt><i>s</i><tt>);<br></tt></code></p></blockquote><h4><a name="tag_03_782_03"></a>DESCRIPTION</h4><blockquote><div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"border="0"> The functionality described on this reference page is aligned with the ISO C standard. Any conflict between therequirements described here and the ISO C standard is unintentional. This volume of IEEE Std 1003.1-2001 defers tothe ISO C standard. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div><p>The <i>tmpnam</i>() function shall generate a string that is a valid filename and that is not the same as the name of anexisting file. The function is potentially capable of generating {TMP_MAX} different strings, but any or all of them may already bein use by existing files and thus not be suitable return values.</p><p>The <i>tmpnam</i>() function generates a different string each time it is called from the same process, up to {TMP_MAX} times.If it is called more than {TMP_MAX} times, the behavior is implementation-defined.</p><p>The implementation shall behave as if no function defined in this volume of IEEE Std 1003.1-2001 calls<i>tmpnam</i>().</p><p><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> Ifthe application uses any of the functions guaranteed to be available if either _POSIX_THREAD_SAFE_FUNCTIONS or _POSIX_THREADS isdefined, the application shall ensure that the <i>tmpnam</i>() function is called with a non-NULL parameter. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></blockquote><h4><a name="tag_03_782_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, <i>tmpnam</i>() shall return a pointer to a string. If no suitable string can be generated, the<i>tmpnam</i>() function shall return a null pointer.</p><p>If the argument <i>s</i> is a null pointer, <i>tmpnam</i>() shall leave its result in an internal static object and return apointer to that object. Subsequent calls to <i>tmpnam</i>() may modify the same object. If the argument <i>s</i> is not a nullpointer, it is presumed to point to an array of at least L_tmpnam <b>char</b>s; <i>tmpnam</i>() shall write its result in thatarray and shall return the argument as its value.</p></blockquote><h4><a name="tag_03_782_05"></a>ERRORS</h4><blockquote><p>No errors are defined.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_782_06"></a>EXAMPLES</h4><blockquote><h5><a name="tag_03_782_06_01"></a>Generating a Filename</h5><p>The following example generates a unique filename and stores it in the array pointed to by <i>ptr</i>.</p><pre><tt>#include <stdio.h>...char filename[L_tmpnam+1];char *ptr;<br>ptr = tmpnam(filename);</tt></pre></blockquote><h4><a name="tag_03_782_07"></a>APPLICATION USAGE</h4><blockquote><p>This function only creates filenames. It is the application's responsibility to create and remove the files.</p><p>Between the time a pathname is created and the file is opened, it is possible for some other process to create a file with thesame name. Applications may find <a href="../functions/tmpfile.html"><i>tmpfile</i>()</a> more useful.</p></blockquote><h4><a name="tag_03_782_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_782_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_782_10"></a>SEE ALSO</h4><blockquote><p><a href="fopen.html"><i>fopen</i>()</a> , <a href="open.html"><i>open</i>()</a> , <a href="tempnam.html"><i>tempnam</i>()</a> ,<a href="tmpfile.html"><i>tmpfile</i>()</a> , <a href="unlink.html"><i>unlink</i>()</a> , the Base Definitions volume ofIEEE Std 1003.1-2001, <a href="../basedefs/stdio.h.html"><i><stdio.h></i></a></p></blockquote><h4><a name="tag_03_782_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 1. Derived from Issue 1 of the SVID.</p></blockquote><h4><a name="tag_03_782_12"></a>Issue 5</h4><blockquote><p>The DESCRIPTION is updated for alignment with the POSIX Threads Extension.</p></blockquote><h4><a name="tag_03_782_13"></a>Issue 6</h4><blockquote><p>Extensions beyond the ISO C standard are marked.</p><p>The DESCRIPTION is updated to avoid use of the term "must" for application requirements.</p><p>The DESCRIPTION is expanded for alignment with the ISO/IEC 9899:1999 standard.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -