_MAX_PATH
is not probably enough to hold the whole value. You should first call the method with a nullptr and size 0 to get the size required and then allocate a buffer of that size.
auto size = GetEnvironmentVariableA("PATH", nullptr, 0);
std::string Buffer(size, 0);
GetEnvironmentVariableA("PATH", &Buffer[0], size);
std::cout << Buffer << std::endl;
UPDATE: For pre C++11 compilers:
DWORD size = GetEnvironmentVariableA("PATH", NULL, 0);