There are a million examples on the interweb detailing the use of sqlite3_exec to select rows from a table and printing them using this callback function:
static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for(i=0; i<argc; i++){
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
}
printf("\n");
return 0;
}
This is the code that implements callback:
[...]
rc = sqlite3_exec(db, sql, callback, &nrecs, &zErrMsg);
[...]
Now, I would assume that using the fetched data for something other than just printing would be a rather standard scenario, but for the life of me I cannot find out how this is supposed to be accomplished.
What I wish to do is fetch one row (argc will be 1) containing two columns and have these two values (argv[0] and argv[1]) accessible from where sqlite3_exec was executed.
I suppose this has something to do with the void *NotUsed. (What in the world is this a pointer to and why do all examples insist on not using it?)
If someone could help me with this i would be ever so grateful. If you could also explain to me why this seemingly trivial task has been made so complicated you will have my undying love. (The fetched data is handled in a static function called from another function. This effectively kills the purpose of using an object oriented language, right?)