views:

97

answers:

1

I created a VC++ console project with Visual Studio and it auto-generated this function:

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { ... }

I was just wondering what envp stands for and how/when I can/should use it?

Thank you!

+5  A: 

The envp argument above will store the environment variables.

The envp array, which is a common extension in many UNIX® systems, is used in Microsoft C++. It is an array of strings representing the variables set in the user's environment. This array is terminated by a NULL entry. It can be declared as an array of pointers to char(char *envp[ ]) or as a pointer to pointers to char(char **envp). If your program uses wmain instead of main, use the wchar_t data type instead of char. The environment block passed to main and wmain is a "frozen" copy of the current environment.

Source

Brian R. Bondy