I am having a problem (or lots of that type) finding a working way to convert some char(s) to Bytef type (used by the zlib).
I am kind of new to C++ programing and syntax so I might be missing something obvious.
Anyhow, here is my program:
#include <iostream>
#include <zlib.h>
using namespace std;
void _compress(unsigned char & in_data, size_t in_size, unsigned char & out_data, size_t out_size){
z_stream z;
int status;
z.avail_in = 0;
z.next_out = &out_data;
z.avail_out = out_size;
if ( z.avail_in == 0 ) {
z.next_in = &in_data;
z.avail_in = in_size; //dfjngdfng
}
if ( z.avail_in != 0 )
status = deflate( &z, Z_NO_FLUSH );
int count = out_size - z.avail_out;
}
int main(){
unsigned char a[100];//13
a=reinterpret_cast<unsigned char>("Hello world!");
unsigned char b[100];
_compress(*b,13,*b,100);
cout << b << endl;
return 0;
}My goal is to make an easy-to-use function that will compress (and later de-compress) a buffer. The error I get with this last compilation attempt is:
sakishrist@sakishrist-laptop:~/Desktop/c++/zlib$ g++ zlib.cpp -o zlib_c -lz zlib.cpp: In function ‘int main()’: zlib.cpp:42:50: error: cast from ‘const char*’ to ‘unsigned char’ loses precision zlib.cpp:42:50: error: incompatible types in assignment of ‘unsigned char’ to ‘unsigned char [100]’I tried many different things but all of them fail. I think (I can be wrong with so many errors) that I know how to use * and & in general.
I hope you can give me a piece of advice. :)
Thanks in advance!!!


Sign In
Create Account


Back to top











