After I call export EXAMPLE="exampleValue"
in terminal. I call command printenv
I can clearly see my new environment variable.
I compile C program and run it and in code I call getenv("EXAMPLE")
.
But it returns null every time, unless I call
getenv("PATH")
or getenv("HOME")
or similar environment variables.
char* env_variable_name;
env_variable_name = getenv("EXAMPLE");
Any explanation why I can't get value of EXAMPLE?