title: How to send command to Linux command from C program
body: <p>I am trying to send a command to a Linux command line from a C program and there is one part I am not sure how to do. </p>
  
  <p>For example in my C code I have</p>
  
  <pre><code>system("raspistill -o image.jpg");
  </code></pre>
  
  <p>What I would like to be able to do is add a number to the end of "image" and increment it every time the program runs, but how can I pass in a variable <code>n</code> to the <code>system()</code> function that is only looking for a <code>const char</code>?</p>
  
  <p>I tried this but it did not work:</p>
  
  <pre><code>char fileName = ("raspistill -o image%d.jpg",n);
  system(filename);
  </code></pre>
  
  <p>I've tried searching on this and haven't found anything about how to add a variable to it. Sorry for the noob question. </p>