title: How to pass a value from shell script to C program
body: <p>I am trying to use system() in C to call shell script to modify a file and execute a executable file and get some output in another directory (not the C working directory). How can I pass the value I got in the shell script to the main C program. Thanks in advance!</p>
  
  <pre><code>#define shell "\
  #/bin/bash \n\
  cd home/path \n\
  "input modification" \n\
  ./ exe \n\ #output a parameter b in the file out
  b=$(cat &lt;out) \n\
  echo "b" \n\
  "
  void main()
  {
   system(shell);
   printf("b=d%",b);
  }
  </code></pre>