可能重复:
用c打开一个rar文件
我必须使用 c 代码提取 rar 文件。首先,我试图找到图书馆。我从http://www.unrarlib.org/得到它。但它是 2002 年构建的。所以它不支持当前的 rar 格式。然后我检查了http://www.rarlabs.com/rar_add.htm。它有库,但在 c++ 中。我对c++一无所知,所以我不能使用它们。我尝试通过使用系统功能来使用命令行工具 unrar。当我在 CMD 中使用 unrar 时,它提取了文件,但是当我在 C 中使用它时,(命令是 system( "unrar -e -p password protected_file.rar"
);)它只是打开了档案。它没有提取文件。现在我不知道下一步该怎么办?有人可以建议我吗?
这是我用来打开 rar 文件的代码。在系统命令中,ranjit 是密码。它在模块+文件名中给出了错误未定义的符号系统。有谁能够帮我??两天以来,我一直在为此苦苦挣扎。
#include<stdio.h>
#include<stdlib.h>
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 >C:\stdout.log 2>C:\stderr.log",file2, file));
getchar();
return 0;
}