I try to retrieve the path environment variable on Windows. Therefore, I tried
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
char* path = getenv("Path");
cout << "current path is:" << path << endl;
cin.get(); // program shall be closed when it's finished
}
This works fine and gives me a path. I compared it to my actual path and found out that the path I retrieved by this program is the system path. However, I don't want to get the system path but rather the user path. I tried to change the case of "Path"
as on my system "path"
refers to the user path variable while "Path"
refers to the system path variable, but getenv
seems to ignore that. How can I get the value of the system path variable?