首先說明這個問題困擾了我很長時間了,嚴格地說應該有兩天,不過終於通過sqlite的官方文檔解決了。
For example, assume the string variable zText contains text as follows:
char *zText = "It's a happy day!";
One can use this text in an SQL statement as follows:
char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText); sqlite3_exec(db, zSQL, 0, 0, 0); sqlite3_free(zSQL);
摘自liuzhidong123的專欄