title: Using variable input for system()
body: <p>I am using an executable made from C, and I am trying to pass variables in R to it.</p>
  
  <p>C code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  int sumUp(int x, int y, int z, int *sum);
  
  int main()
  {
      int x1,x2,x3;
      int total = 0;
  
      scanf("%d %d %d",&amp;x1,&amp;x2,&amp;x3);
      sumUp(x1,x2,x3,&amp;total);
      printf("Your total is :%d\n", total);
  
      system("pause");
  
  }
  
  int sumUp(int x, int y, int z, int *sum)
  {
      *sum = x + y + z;
  }
  </code></pre>
  
  <p>and Here is my R code:</p>
  
  <pre><code>x &lt;- 0
  y &lt;- 0
  z &lt;- 0
  
  readint &lt;-function(){
    a &lt;- readline(prompt = "Enter a number: \n")
  }
  
  x &lt;- as.numeric(readint())
  y &lt;- as.numeric(readint())
  z &lt;- as.numeric(readint())
  
  system("Practice.exe", intern = TRUE,input = "x y z")
  </code></pre>
  
  <p>I am having an issue when I use variables for <code>input</code> as it will print an incorrect value. However, when I use direct input, like <code>input = "1 2 3"</code>, I will get the correct answer. I checked the types for for my variables, and they seem to be correct. Here is the output for reference:<a href="https://i.stack.imgur.com/kqwoa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kqwoa.png" alt=""></a><a href="https://i.stack.imgur.com/t1RgA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t1RgA.png" alt=""></a></p>
  
  <p>Is there something wonky going on between R and C, or am I doing something incorrect with <code>system</code>? Even if I vary the values of <code>x,y,z</code>, I will get <code>84</code>. So I imagine there is something going on under the hood here that I am missing. I tried using <code>args</code> instead of <code>input</code>, but ran into the same issue, except that it gave a value of <code>126</code> no matter what I entered, variable or directly. Any help is appreciated, thank you.</p>