SQLite Forum

how to save results of
Login
> the call back function print the correct data.
>
> BUT,how do I save this results into array or file

There is an argument to your callback function that you called `void *NotUsed`. Note that [it is passed from the second-to-last argument to `sqlite3_exec`](https://sqlite.org/c3ref/exec.html). You can use it to pass your callback a `FILE*` to `fprintf` into or a pointer to append data to.

Take a look at the [implementation of the `sqlite3_get_table()` function](https://sqlite.org/src/file?name=src/table.c&ci=tip) (not recommended for use) for some inspiration on how to allocate a memory for an unknown number of rows while receiving them in the callback. Perhaps the usual sequence of `sqlite3_prepare_v2()` / `sqlite3_bind_*()` / loop on `sqlite3_step()` / `sqlite3_finalize()` will result in cleaner code?