tmp-name.c

来自「linux下的C语言开发」· C语言 代码 · 共 46 行

C
46
字号
/*-*//******************************************************** * Question:						* *	Why does the following program print		* *	Name1: @$@#$#@$@				* *	(Your results may vary)?			* ********************************************************//*+*/#include <stdio.h>#include <string.h>/******************************************************** * tmp_name -- return a temporary file name		* *							* * Each time this function is called, a new name will	* * be returned.						* *							* * Returns						* * 	Pointer to the new file name.			* ********************************************************/char *tmp_name(void){    char name[30];	/* The name we are generating */    static int sequence = 0;	/* Sequence number for last digit */    ++sequence;	/* Move to the next file name */    strcpy(name, "tmp");    /* But in the squence digit */    name[3] = sequence + '0';    /* End the string */    name[4] = '\0';    return(name);}int main(){    char *tmp_name(void);	/* get name of temporary file */    printf("Name: %s\n", tmp_name());    return(0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?