mysql++

I am inserting a unsigned char* array into table column that is BLOB and is binary. The data inserts fine.
unsigned char* templByte;
.
.
.
string temp;
stringstream ss;
for(i = 0; i < size; i++)
{
ss << templByte[i];
}
temp = ss.str();


query << "INSERT INTO table (data) VALUES('" <<
mysqlpp::escape << temp << "')";
SimpleResult res2 = query.execute();


My issue now is getting the data back into an unsigned char* array

I am trying

Query query2 = database->con->query("SELECT id,data FROM table");
mysqlpp::StoreQueryResult res = query2.store();
unsigned char* tp = (unsigned char*)&res[0][1];

to no avail.

Any help would be greatly appreciated. Thanks.
I don't think the operator[] for StoreQueryResult allows for 2d array semantics. Just perusing the documentation it appears it is a specialization of std::vector.
It is a vector so it is fine.

I did solve my problem.

i used memcpy instead.

The data had a terminating characters in it so it caused the cast to end to early.

Topic archived. No new replies allowed.