c - C 编程中的 Winzip 命令行

标签 c unzip winzip

我想使用c编程使用winzip命令行解压缩文件,我编写了以下代码,但执行后显示系统命令无法识别内部或外部命令

  #include <stdio.h>
  #include <stdlib.h>
  #include<conio.h>
  #include <string.h>

 void fmuUnzip() {
char fmuFileName[100], path[100],strFinal[100];
char unzip[512]="wzunzip";
printf("Enter fmuFileName\n");
gets(fmuFileName);

printf("Enter path of the fmuFileName\n");
gets(path);
strcat(unzip," ");
strcat(unzip,fmuFileName);
strcat(unzip," ");
strcat(unzip,path);
//printf("The string is : %s",unzip);
system(unzip);
 //getch();
 }

 void fmuLoad() {
 fmuUnzip();
}

int main(int argc,char* argv[]) {
 fmuLoad();
}

最佳答案

特别是在 Windows 系统中,新程序不会自动成为系统路径的成员,您应该使用命令的完整路径。

在您的示例中,您应该编写:

char unzip[512]="\"C:\\Program Files\\WinZip\\WZUNZIP.EXE\"";

注意 \\ 以在 C 字符串中包含真正的 \,以及开头和结尾的 " 以强制 系统调用将路径视为单个单词 - 感谢@willywonka_dailyblah注意到它

关于c - C 编程中的 Winzip 命令行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31425341/

相关文章:

Java计算解压缩过程的进度

zip - 尝试在命令行中静默执行自解压 zip 文件

linux - 压缩命令不起作用

c - 为什么 sscanf() 或 strtoll() 不将超过 9 个字节的十六进制字符串转换为十六进制数

java - 无法解压 EPub 文件

c - Linux环境变量使用非全路径

linux - 如何获取 zip 中的目录列表?

c - segmentation fault和segmentation fault core dumped的区别

c - OpenGL矩形动画