I use the following code on OSX and on Windows Vista:
#include <stdio.h>
#include <string.h>
extern char **environ;
int
main(int argc, char **argv)
{
int i;
for (i = 0; environ[i] != NULL; i++)
{
printf("var = %s - %d\n", environ[i], (int)strlen(environ[i]));
}
return 0;
}
On OSX, compile it with cc, on Windows with 'cl' from the Windows SDK 7.1 (with redistributable packages: Microsoft Visual C ++ 2010 in it).
I define the same ENV variables in both OSs in Russian: MY_ENV = 'Russian letters go here'. And they got a difference of about 2 times the length of the lines.
This is the length that I plan to use in malloc, and I want them to be the same. How can I get the same lengths correctly on CRT?
egor7 source
share