This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/snprintf.c

25 lines
452 B
C
Raw Permalink Normal View History

#include <stdio.h>
/* Create temporary file names using a counter */
char namebuf[13];
int TempCount = 0;
char *make_temp_name()
{
_snprintf( namebuf, 13, "ZZ%.6o.TMP", TempCount++ );
return( namebuf );
}
void main()
{
FILE *tf1, *tf2;
tf1 = fopen( make_temp_name(), "w" );
tf2 = fopen( make_temp_name(), "w" );
fputs( "temp file 1", tf1 );
fputs( "temp file 2", tf2 );
fclose( tf1 );
fclose( tf2 );
}