我想使用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/