C++ tmpnam alternative
问题 I have a C++ library that uses tmpnam(NULL) to create a temporary file. I need to hack this because it makes the temp file in the root folder ("c:" or "/") and so it needs the administrative privileges. How can I change this function with other one using a valid temp path? Thanks. 回答1: Though tmpnam returns a filename pre-pended by / - it actually denotes a unique filename in the current directory and not / or c:\ . So you can chdir to any other directory before calling tmpnam to find a