I would like to know how to check if I have write permissions to a folder.

I'm writing a C++ project and I should print some data to a result.txt file, but I need to know if I have permissions or not.

Is the check different between Linux and Windows? Because my project should run on Linux and currently I'm working in Visual Studio.