title: extract a rar file by c code
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3514854/opening-a-rar-file-by-c">opening a rar file by c</a>  </p>
  </blockquote>
  
  
  
  <p>I have to extract a rar file using c code. First I tried out to find the libraries. I got it from <a href="http://www.unrarlib.org/" rel="nofollow noreferrer">http://www.unrarlib.org/</a>. But it was built in 2002. So it do not support the current rar format. Then I checked <a href="http://www.rarlabs.com/rar_add.htm" rel="nofollow noreferrer">http://www.rarlabs.com/rar_add.htm</a>. It have libraries but in c++. I don't know anything about c++, So I can't use them. I tried to use the command line tool unrar by using system function. When I used unrar in CMD , It extracted the file but when I used it in C, (command was system(<code>"unrar -e -p password protected_file.rar"</code>);)
  It just opened the archieve. It did not extract the file. Now I don't know what to do next? Can anybody suggest me something??</p>
  
  <p>This is the code I am using to open the rar file.In the system command ranjit is the password. It's giving the error undefined symbol_system in module+thefile name.
  Can anybody help me?? I am struggling on this since two days. </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  int main(int argc, char **argv)
       {
       char file[20];
       char file2[50] = "F:\\Program Files\\WinRAR\\unrar.exe";
       printf("enter the name of the rar file : ");
       gets(file);
       puts(file);
       system(("%s e -p ranjit %s &gt;C:\stdout.log 2&gt;C:\stderr.log",file2, file));
       getchar();
       return 0;
       }
  </code></pre>