tmpnam
来自cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Defined in header <stdio.h>
|
||
| char *tmpnam( char *filename ); |
||
创建一个唯一的文件名,并将其存储在字符串中指出,
filename。该功能能够产生高达TMP_MAX唯一的文件名,但是它们中的一些或全部可能是在文件系统中的使用,从而不适合的返回值. Original:
Creates an unique filename and stores it in character string pointed to by
filename. The function is capable of generating up to TMP_MAX of unique filenames, but some or all of them may be in use in the filesystem and thus not suitable return values. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目录 |
[编辑] 参数
| filename | - | 的结果缓冲器被用来作为字符串的指针。如果
NULL传递,返回一个指针,指向一个内部静态缓冲区.Original: pointer to the character string to be used as a result buffer. If NULL is passed, a pointer to an internal static buffer is returned.The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[编辑] 返回值
filename如果filenameNULL。否则,返回一个指针,指向一个内部静态缓冲区。如果没有合适的文件名,可以产生NULL返回.Original:
filename if filename was not NULL. Otherwise a pointer to an internal static buffer is returned. If no suitable filename can be generated, NULL is returned.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 为例
#include <stdlib.h> #include <stdio.h> #include <stdint.h> #include <stdbool.h> int main(int argc, char *argv[]) { printf("Welcome to %s\n", argv[0]); printf("Called with %u arguments\n", argc - 1); char buffer[L_tmpnam] = {'\0'}; tmpnam(buffer); printf(buffer); printf("\n"); printf("Goodbye!\n"); exit(EXIT_SUCCESS); }
Output:
Welcome to ./main_release Called with 0 arguments /tmp/file6HADua Goodbye!
[编辑] 另请参阅
| 返回一个指针到一个临时文件中 Original: returns a pointer to a temporary file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
| C++ documentation for tmpnam
| |