Skip to content
Advertisement

Retrieve Sqlite table data in C++

I have the code as below. I am trying to simply get data from a table i have already created. How do i get the data in the array p_fields that is defined in the callback function into a variable in main. Can i define a char ** array in main and copy the data somehow into it in the callback function?

Thanks very much, Shyam.

Advertisement

Answer

You need to pass the array where you want to store the data in as the 1st argument to the callback as shown in sqlite3 docs

Here’s a contrived example based on your code with some tidy up:

Your question is tag c++, so I’ve removed your use of the standard c api calls in favour of standard c++.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement