title: Set system variable from C++
body: <p>This shell script</p>
  
  <pre><code>#!/bin/csh
  set VAR=12345
  echo $VAR
  </code></pre>
  
  <p>will peacefully give the output 12345 at shell. 
  I need to use C++ to do the same in some part of the code:</p>
  
  <pre><code>string str = "12345";
  retValue="set var1= "+str;      
  system(retValue1.c_str());
  system("echo $var1");
  </code></pre>
  
  <p>This doesn't create a system variable var1 and echos null which is understandable as each system function would create a child process with different environment variables. So I combine them as follows using just one system function...but it echos null again.</p>
  
  <pre><code>retValue="set var1= "+str;
  retValue1=retValue+";\n echo $var1";
  system(retValue1.c_str());
  </code></pre>
  
  <p>Can someone please guide me to set up the system variable thru C++. 
  Thanks a lot in advance!</p>