13

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!

Kate Gregory
  • 18,565
  • 8
  • 53
  • 85
Simon
  • 8,777
  • 4
  • 35
  • 53

1 Answers1

12

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
  • 314,085
  • 114
  • 576
  • 619