I had some doubts about fopen...
Can i perform the following?
fopen("%temp%" , "r");
or do i need to use windows specific functions?
I had some doubts about fopen...
Can i perform the following?
fopen("%temp%" , "r");
or do i need to use windows specific functions?
No, you cannot do directly (unless you want to open file called
%temp
). There is a functionExpandEnvironmentStrings
that does that:You can do that manually -- in this case it can be more portable:
But there is a cleaner option for your case --
tmpfile
On Windows you can use GetTempPath function that simply expands your
%TEMP%
env variable.Note, that starting from C++17 you can use std::filesystem::temp_directory_path