title: Is there a way to run two programs simultaneously in C and records the output
body: <p>I have two programs in C almost the same (with a little different) and I have (key/value) dictionary in another C file</p>
  
  <p>The following steps are done for both programs</p>
  
  <p>compile the first program</p>
  
  <pre><code>gcc file1.c dict.c
  </code></pre>
  
  <p>compile the second program</p>
  
  <pre><code>gcc file2.c dict.c
  </code></pre>
  
  <p>and inside the file.c I called both functions update(to fill the dictionary) and printDic (to print the content of dictionary)</p>
  
  <pre><code>//file1.c
  int func(int w){
    update("w",w) 
    if ((w &gt;= w) &amp;&amp; ((w % w) == 0))
    {
      w= w*4
      update("w",w) 
      printDic();
    }
    else
    { 
      w=1;
      update("w",w) 
      printDic();
    }
    return 0; }
  
  //file2.c
  int func(int w){
    update("w",w) 
    if ((w &gt;= 4) &amp;&amp; ((w / w) == 0))
    {
      w = w/2;
      update("w",w)
      printDic();
  
    }
    else
    { 
      w=0;
      update("w",w)
      printDic();
    }
    return 0; }
  </code></pre>
  
  <p>and both files have the same main </p>
  
  <pre><code>//main
   int main(int argc, char *argv[]){
       func(10);
       func(5);
       func(2);
       func(0);
       func(180);
  
      return 0; }
  </code></pre>
  
  <p>So, the update() will fill the dictionary with the values of w once they change and then print them.</p>
  
  <p>Is there a way to run these two files with the dictionary at once, in order to compare the output e.g. if I pass 10 in both programs will end up with a different value of w (which is stored in the dictionary).</p>
  
  <p>Note: I need to call the func many times and in the same file I don't want to run the program each time with only one call.</p>
  
  <p>the dictionary is working very well with one file and in each call to func the value of w is append to txt file.</p>