ОК, теперь я на полпути, вот что я сделал:
`int main(int argc,char* argv[]){
FILE *inputFile,*outputFile;
unsigned char *inputBuffer, *outputBuffer;
unsigned char *readMod = "r";
int result,x;
long int outputSize;
long int outputSizeun;
size_t inputSize;
if(argc >= 3){
inputFile = fopen(argv[2],readMod );
// get length of input
fseek(inputFile, 0, SEEK_END);
inputSize = ftell(inputFile);
fseek(inputFile, 0, SEEK_SET);
//allocate the inputBufer size
inputBuffer = (unsigned char *)malloc(inputSize);
fread(inputBuffer, 1, inputSize, inputFile);
outputSize = EZ_COMPRESSMAXDESTLENGTH(inputSize);
//allocate the outputBuffer size
outputBuffer = (unsigned char *)malloc(outputSize);
//check for the -z(compression)/-u(decompression) option s
if(strcmp("-z",argv[1])==0){
result = ezcompress(outputBuffer, &outputSize, inputBuffer, inputSize);
}else if(strcmp("-u",argv[1])==0){
result = ezuncompress(outputBuffer, &outputSizeun, inputBuffer, inputSize);
}else{
printf("Error : unknown operation \" %s \" type -z for compression or -u for decompression\n",argv[1]);
}
if (result == 0) {
// if the output filename was not present it output the compressed data into a file named "compress"
if(argv[3] == NULL){ argv[3] = "output";}
//write the output
outputFile = fopen(argv[3], "w");
fseek(outputFile, 0, SEEK_END);
fseek(outputFile, 0, SEEK_SET);
fwrite(outputBuffer, 1, outputSize, outputFile);
fclose(outputFile);
} else {
// Something went wrong
printf("%d ",result);
}
//now freeing buffers
free(inputBuffer);
free(outputBuffer);
}else{
printf("insufficnt Arguments :-s");
return 1;
}
return 0;
}
почему этот код возвращает -3, когда я запускаю ** a.exe -u вывод