Linux Enviroment Variable and C project getenv() -
i need use environment variable c project did in terminal:
export file_config="/home/pc/file.conf"
file.conf file created.
if env
in terminal, can see "file_config" in list value (/home/pc/file.conf). want assign path_to_config -> /home/pc/file.conf in .c program did this:
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { char* path_to_config = getenv("file_config");
but getenv
doesn't returns path file_config.. when in debug mode path_to_config value 0x0. i've tried other environment variables not 1 in particular exported.
let me guess: running program ide. environment ide provides program totally unrelated environment export variable. suggestion: run program command line at terminal in did export
. shall see variable right.
then search ide way specify environment target program, , set there.
optionally, add export line shell's startup script.
Comments
Post a Comment