We have a lot, a lot of temporary file open/creation utilities, could you use one of them? This method is technically insecure for a number of use cases (Not to mention rand() is discouraged in C++14)