I'm trying to use c++ vectors to store pointers to a structure like so :
struct SourceDir {
int id;
const unsigned char *alias;
const unsigned char *description;
const unsigned char *path;
};
but then, I cannot retrieve the value, which seems corrupted
std::vector<SourceDir*> source_dirs;
while ((step = sqlite3_step(stmt)) != SQLITE_DONE) {
if (step != SQLITE_ROW) {
std::cerr << "[ERROR] internal error (SQLite error code" << step << ")\n";
exit(1);
}
struct SourceDir *sourceDir = new SourceDir;
sourceDir->id = sqlite3_column_int(stmt, 0);
sourceDir->alias = sqlite3_column_text(stmt, 1);
sourceDir->path = sqlite3_column_text(stmt, 2);
sourceDir->description = sqlite3_column_text(stmt, 3);
source_dirs.push_back(sourceDir);
}
for (std::vector<SourceDir*>::iterator it = source_dirs.begin() ; it != source_dirs.end() ; ++it) {
SourceDir *s = *it;
std::cerr << s->description << "\n";
}
it gives random values like so :
@O?V
@O?V
I don't understand what I did wrong
Please login or Register to submit your answer