RunningPig RunningPig - 1 year ago 106
Linux Question

How to pass environment variable to C++ program in Unix

I recently wrote a C++ program that opens a file and reads it. If I want to run the program in Unix/Linux and the file name and path will be a environment variable. How can I achieve it?

Thank you.

Answer Source

Use getenv(char const *name) of the stdlib.h. Note, however, that environment variables are a quite unclean way to pass parameters.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download