1

我有一个表字段,其中值存储为BLOB类型。我需要将其作为二进制数组获取,以便可以从 BLOB 中的不同字节位置获取不同的值。任何帮助表示赞赏。

4

1 回答 1

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];
于 2012-08-25T08:33:09.037 回答