Reputation: 1629
I am trying to create file in main directory of operation system(for example Windows in my "c" disk) using c++. Is there any better way than iterating all disks and search for "Windows" folder? Also its similar in mac and linux?
Upvotes: 0
Views: 200
Reputation: 22157
In Windows, you can call GetWindowsDirectory
function (link). In Linux and Mac (I think), there's no such thing as main system directory.
However, as David noted, you should not put any files there:
This function is provided primarily for compatibility with legacy applications. New applications should store code in the Program Files folder and persistent data in the Application Data folder in the user's profile. For more information, see ShGetFolderPath.
Upvotes: 1