lundi 26 janvier 2015

How can I adding the value in 2D vector std::vector< std::vector >


I was using this code, but the items result inside the vetore are the same. Whereas the data from the db queriying are varied.



std::vector< std::vector<char*> > results;
char *dataTemp = new char[128];
sqlite3_stmt *statement;
int rc = sqlite3_prepare_v2(m_pDbFile, sql, -1, &statement, 0);
if( rc == SQLITE_OK )
{
int cols = sqlite3_column_count(statement);
int result = 0;
int count = 0;
while(true)
{
result = sqlite3_step(statement);
if(result == SQLITE_ROW)
{
std::vector<char*, std::allocator<char*>> values;
for(int col = 0; col < cols; col++)
{
char* value = (char*)sqlite3_column_text(statement, col);
values.push_back((char*)sqlite3_column_text(statement, col));
}
results.push_back(values);
}
else
{
break;
}
count++;
}

sqlite3_finalize(statement);
}

Aucun commentaire:

Enregistrer un commentaire