Set environment variables in C

后端 未结 4 943
我在风中等你
我在风中等你 2020-11-28 08:02

Is there a way to set environment variables in Linux using C?

I tried setenv() and putenv(), but they don\'t seem to be working for me.

4条回答
  •  难免孤独
    2020-11-28 08:39

    The environment block is process-local, and copied to child processes. So if you change variables, the new value only affects your process and child processes spawned after the change. Assuredly it will not change the shell you launched from.

提交回复
热议问题