我想在創建char數組時添加一些變量。我怎樣才能做到這一點? sqlite3_prepare_v2
需要char[]
。感謝在C++中的char數組,並將它與其他合併
unsigned int keyid = 10;
char buffer2[] = "SELECT * FROM table WHERE id = " + keyid; // problem (convert to char and merge)
sqlite3_prepare_v2(db, buffer2, strlen(buffer2), &stmt, 0);
使用'std :: string'。 char []沒有運算符重載字符串連接。然後你可以使用'std :: c_str()'來獲得一個const char * – hetepeperfan
小心小Bobby表;-) http://xkcd.com/327/ – doctorlove