RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: C++
Expertise: Intermediate
Nov 6, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Creating a Temporary File

Many applications create temporary files that exist as long as the program is running and are later discarded. For example, a Web browser can store a list of pages that have been viewed during the current browsing session and redisplay them when you press "Back". The problem is that most applications don't delete these temporary files after the application is closed. Instead, they store them in a special directory that you have to clean manually. A better approach is to use the standard function tmpfile(), which is declared in <stdio.h> as follows:

FILE * tmpfile();

tmpfile() opens a temporary file for read/write operations and returns a pointer to to that file. tmpfile() uses unique filenames to avoid conflicts with any existing files. The temporary files created by tmpname() are automatically deleted when the program terminates so you don't have to manually delete them.

Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date