Note that there are some explanatory texts on larger screens.

plurals
  1. POneed an example on easyzlib (how to compress and decompress strings sent in the argv from command line Windows/Linux)
    primarykey
    data
    text
    <p>OK now am half the way ,This is what i've done:</p> <pre><code>`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 &gt;= 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, &amp;outputSize, inputBuffer, inputSize); }else if(strcmp("-u",argv[1])==0){ result = ezuncompress(outputBuffer, &amp;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; } </code></pre> <p><strong>why does this code returns -3 when i run **a.exe -u output</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload