title: c++ linux system command
body: <p>I have the following problem: </p>
  
  <p>I use in my program this function:</p>
  
  <pre><code>  system("echo -n 60  &gt; /file.txt"); 
  </code></pre>
  
  <p>it works fine.</p>
  
  <p>But I don't want to have constant value. I do so:  </p>
  
  <pre><code>   curr_val=60;
     char curr_val_str[4];
     sprintf(curr_val_str,"%d",curr_val);
     system("echo -n  curr_val_str &gt; /file.txt");
  </code></pre>
  
  <p>I check  my string:</p>
  
  <pre><code>   printf("\n%s\n",curr_val_str);
  </code></pre>
  
  <p>Yes,it is right.
  but <code>system</code> in this case doesn't work and doesn't return -1. I just print string!</p>
  
  <p>How can I transfer variable like integer that will be printed in file like integer, but don't string?</p>
  
  <p>So I want to have variable  int a  and I want to print value of a with system function in file. A real path to my file.txt is /proc/acpi/video/NVID/LCD/brightness. I can't write with fprintf. I don't know why.</p>