How to use setenv() to export a variable in c++?

后端 未结 3 561
感情败类
感情败类 2020-12-01 16:36

I need to export several variables such that they look like the following in the command line

export ROS_HOSTNAME=xxx

How do I use setenv()

3条回答
  •  天涯浪人
    2020-12-01 17:04

    Do like this:

    setenv("ROS_HOSTNAME", "xxx", true);
    

    Note it's synopsis as well:

    #include 
    
    int setenv(const char *envname, const char *envval, int overwrite);
    

    See this link for more details on setenv().

提交回复
热议问题