简体   繁体   中英

How to remove tmpnam generated file in other folder from c:/ folder in c/c++

My code is like this

  char buffer [L_tmpnam];
  char * pointer;
  tmpnam (buffer);
  strcat (buffer, "mux");

so it generates random ".mux" file in "C:\\". I want to remove those generated ".mux" file from "C:\\" to "C:\\Mytemp" folder .

Please help me.

Since you're on Windows, you could use GetTempFileName, passing GetTempPath's result as the first argument. Example on how to use it is here:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa363875(v=vs.85).aspx

according to man tmpnam

The pathname that is created, has a directory prefix P_tmpdir.  (Both L_tmpnam and P_tmpdir are defined in  <stdio.h>

change that string to particular directory you want to store file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM