我有一个表格,其中值存储为 BLOB 类型。我需要将其作为二进制数组,以便我可以从BLOB中的不同字节位置获取不同的值。任何帮助表示赞赏。
答案 0 :(得分:0)
// Get the start and length of the blob.
// (remember column indexes are 0-based when fetching the value
// but 1-base when binding - yeah cheers!)
uint8_t *data = (uint8_t *)sqlite3_column_blob(stmt, columnIndex);
size_t length = (size_t)sqlite3_column_bytes(stmt, columnIndex);
// And now you can access the data
unsigned sum = 0;
for (size_t i = 0; i < length; i++)
sum += data[i];