【问题标题】:Winzip command line in c programmingc语言中的Winzip命令行
【发布时间】:2015-07-15 08:34:18
【问题描述】:

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

  #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();
}

【问题讨论】:

  • 尝试在你的命令行上运行wzunzip,你应该得到同样的错误。
  • 是的,我遇到了同样的错误
  • @moffeltje 我在命令提示符中也遇到了同样的错误,即使我已经在我的系统中安装了 winzip
  • 嗯,这就是问题所在。重新启动计算机或找到可执行文件或重新安装
  • 您是否尝试传递程序wzunzip (char unzip[512]="/full/path/to/wzunzip";) 的完整路径?

标签: c unzip winzip


【解决方案1】:

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

在你的例子中,你应该写:

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

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

【讨论】:

  • 或者我需要更改站点kb.winzip.com/kb/entry/288中给出的路径变量
  • 在路径两边加上双引号,\" - 因为“Program Files”里面有一个空格,这意味着shell会寻找“C:\\Program”
  • @willywonka_dailyblah : 感谢您的关注 - 编辑后
猜你喜欢
  • 1970-01-01
  • 2011-10-16
  • 1970-01-01
  • 1970-01-01
  • 2011-01-16
  • 2021-11-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多