0

我想使用 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();
}
4

1 回答 1

1

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

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

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

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

于 2015-07-15T10:24:34.713 回答