How do I obtain the AppData or equivalent folder path in C++ that works on Linux and Windows?

65 views Asked by At

I am making a game and I'm using the AppData\Roaming folder to store the file that contains the high score. I'm using the _dupenv_s() function to get the path to this folder.

However, on Linux the _dupenv_s() function throws an error: ā€˜_dupenv_s’ was not declared in this scope, even though the code is completely the same (other than \\ being converted to /, but that shouldn't matter).

I made sure to include all the necessary libraries such as <stdlib.h>, so that probably isn't the problem.

I could make different versions for Linux and Windows but I'd like the code to be the same for both operating systems.

Is there a way to get the path to AppData\Roaming or equivalent folder (e. g. ~/.local/) in C++?

0

There are 0 answers