I am trying to port an application from windows to linux.
In windows I have a GetEnvironmentStrings() function in windows.h which provides me the environment variables and their values in the current process in the form NAME=VALUE.
For Linux I use the environ variable like this
for (char **en=environ; *en; en++) {
std::string str(*en)
env.push_back(str); //env is a vector of strings
}
still the application doesn't seem to work. In windows when I print the size of string passed to the env vector (a vector of strings) it prints the size of all the strings as 48 bytes.
whereas on Linux the size is 8. The original application uses the Unicode version (GetEnvironmentStringsW) and
translate the returned wide-string to an 8-bit string using a conversion function WideCharToMultiByte.
I don't have enough knowledge abt character encodings, but I guess it has something to do with the way strings are encoded. Any idea what could be going wrong?