# Include <stdio. h>
# Include <iostream>
# Include <string>
# Include <windows. h> // header files required for functions such as multibytetowidechar
Using namespace STD;
# Include "SQLite \ sqlite3.h"
Int importdata () // Test
{
Sqlite3 * SQLite;
Sqlite3_open ("E: \ info. DB", & SQLite); // info. DB has the varchar field line and line_name in advance.
Char STR [256] = "experiment ";
Wchar * stra;
Int I = multibytetowidechar (cp_acp, 0, (char *) STR,-1, null, 0 );
Stra = new wchar [I];
Multibytetowidechar (cp_acp, 0, (char *) STR,-1, stra, I );
I = widechartomultibyte (cp_utf8, 0, stra,-1, null, 0, null, null );
Char * strb = new char [I]; //
That is, the required type.
Widechartomultibyte (cp_utf8, 0, stra,-1, strb, I, null, null );
Char strsql [1024] = {0 };
Sprintf (strsql, "insert into line (line_name) values ('% s')", strb );
Sqlite3_stmt * stmt;
Char ** err = NULL;
Int reterr;
Sqlite3_exec (SQLite, strsql, null, null, err );
// Strb is what you want
Delete [] stra;
Delete [] strb;
Sqlite3_close (SQLite );
Return 0;
}