title: Using popen() to open a program in command line?
body: <p>Is it possible to open a program using another program? For example:
  I want to make a command line application in C that will prompt the user to type in the name of a program (lets say Microsoft Word.app), and that program will launch. Would I do something like this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  int main (int argc, const char * argv[]) {
      char programName[1000];
      printf("Type in the name of the program you would like to open: ");
      scanf("%s", programName);
      popen(programName);
  }
  </code></pre>
  
  <p>However, popen() asks me for another char. How would I go about using popen() to open the program?</p>
  
  <p>EDIT: The following code works!</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  
  int main (int argc, const char * argv[]) {
      char programName[1000];
      char app[100] = ".app";
      char openApp[100] = "open /Applications/";
      printf("Type in the name of the program you would like to open: ");
      scanf("%s", programName);
      strcat(openApp, programName);
      strcat(openApp, app);
      system(openApp);
  
  }
  </code></pre>