The
p_Daten is the address of the number pointer (which you have set to NULL).
So inside your callback you can do something to the number (
anzahl), like allocate memory or something.
p_Daten is a local (read: temporary) variable, so you can assign anything you want to it, but once the callback returns whatever you did is lost.
The same is true for
argv[
n]. Everything in
argv[] is a temporary variable, so if you remember the address of any one of them it is meaningless once the callback returns.
Finally, it looks like you are mixing data types.
anzahl is a pointer to
int, but the returned record is a pointer to
char. You need to convert from char* to int.
This will remember the number from the
last record returned:
1 2 3 4
|
char zErrMsg[ MAX_STRING ];
unsigned int anzahl;
int rc = sqlite3_exec( this->Database, sql.str().c_str(), calllback_getanz, &anzahl, &zErrMsg );
if (anzahl < ANZTEILNEHMER) ...
|
1 2 3 4 5 6
|
int calllback_getanz( void *p_Daten, int argc, char **argv, char **SpaltenNamen )
{
if (argc < 1) return 0;
*(unsigned int*)p_Daten = strtoul( argv[ 0 ], NULL, 0 );
return 0;
}
|
All it does is translate the string version of the number in
argv[ 0 ] (if any) to an actual number and store it in
anzahl for
every record returned. Since each record's number overwrites the last number placed in
anzahl only the last record's number is available after the call to
sqlite3_exec().
BTW. You don't need to name your callback calllback_anything(). You can name it whatever you like.
Hope this helps.