I am transitioning a program that uses temporary files from POSIX FILE to C++ standard library iostreams. What’s the correct alternative to mkstemp?
I am transitioning a program that uses temporary files from POSIX FILE to C++
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no portable C++ way to do it. You need to create a file (which is done automatically when opening a file for writing using an
ofstream) and thenremoveit again when you’re finished with the file (using the C library function remove). But you can usetmpnamto generate a name for the file: