In this example,
*just giving the const char * value as an input(ie::test one)
*converting const char * to std::string
*passed the value of std::string to compress the string
*string compressed and can able to see the value of the compressed String
*eg::compressed String::x�+I-.Q��Ko#
*Now converting the std::string of compressed data to const char *...
*when i 'm doing this step ,getting only 75% of the data.few data's went missing.
Eg:: x�+I-.Q��K
*what shall i need to do inorder to get the whole data?
*Can someone help me in this regard?
int main ( int argc,char *argv[] )
{
const char *str = "test one";
int length = 0;
std::string compressionString(str);//converting char * to std::string
cout << "compressionString::" << compressionString<< endl;
while(*(str+length))
length++; //length of char *
cout << "Length of entered string:: " <<length << endl;
std::string compStr = compress_string(compressionString);//Compress the string using compress_string()
cout << "compressed String::"<<compStr << endl;
const char* m_pcompCharptr = compStr.c_str();
cout << "Compressed string char* length::"<< sizeof(m_pcompCharptr) <<endl;
cout << "Compressed value which is present in char * is :: " <<m_pcompCharptr << endl;
cout << "Compressed String length:: " << compStr.length() << endl;
int iCompLen = compStr.length();
cout << "iCompLen::" << iCompLen << endl;
std::string decompressionString(m_pcompCharptr);//converting const char* to std::string
std::string decompStr = decompress_string(decompressionString);
cout << "decompStr::" << decompStr << endl;
return 0;
}
Output::
compressionString::test one
Length of entered string:: 8
compressed String::x�+I-.Q��Ko#
Compressed string char* levgth::8
Compressed value which is present in char * is :: x�+I-.Q��K
Compressed String length:: 16
iCompLen::16
terminate called after throwing an instance of 'std::runtime_error' what(): Exception during zlib decompression: (-5) Aborted (core dumped)
Aucun commentaire:
Enregistrer un commentaire