Chapter Contents

Previous

Next
tmpfile

tmpfile



Create and Open a Temporary File

Portability: ISO/ANSI C conforming, UNIX compatible, POSIX.1 conforming


SYNOPSIS
DESCRIPTION
RETURN VALUE
PORTABILITY
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <stdio.h>

FILE *tmpfile(void);


DESCRIPTION

tmpfile creates a temporary file. You can open the file for both reading and writing. When you close the file, it is deleted. Note that the meanings of the words create and temporary are system dependent.

For programs compiled with the posix option, the temporary file created by tmpfile is an HFS file in the directory /tmp . For non- posix -compiled programs, the file is an OS/390 or CMS disk file suitable for "rel" access. For OS/390 non- posix -compiled programs, a file created by tmpfile is a true temporary file, and is deleted at the end of the job step or TSO session, even if the program terminates abnormally. For posix -compiled programs or programs on CMS, a file created by tmpfile is not deleted if the calling program is terminated abnormally.


RETURN VALUE

tmpfile returns a pointer to the FILE object associated with the temporary file (or NULL if the temporary file cannot be created).


PORTABILITY

Temporary files, either created through the tmpfile function or through the UNIX style I/O functions, vary with the operating system. However, tmpfile is portable unless a program depends on special properties of "rel" files.


EXAMPLE

See the example for fscanf .


RELATED FUNCTIONS

tmpnam


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.