Wondering if anyone has used SQLite. I'm having trouble with the basics.
sqlite3_get_table function.

The Apress book 'The Definitive Guide to SQLite' provides the following example. The first problem is that when declaring char *result[]; Things start to go wrong.

I get an error message saying that 'the size of result can't be determined'.
On top of this, I can't seem to get the &nrows and &ncols arguments right. The compiler keeps telling me that I can't compare an int to a char. I'm just not sure how to interpret the arguments for this. Specifically in the Sqlite3_get_table function. The book by Apress, 'The Definitive Guide to Sqlite' I'm finding very difficult to follow.. Would anyone be able to provides some tips on how to get the below working. I'll put my table below the code.

int main(int argc, char **argv)
{
    /* Connect to database, etc. */

    char *result[];
    sql = "select * from episodes;";
    rc = sqlite3_get_table(db, sql, &result, &nrows, &ncols, &zErr);

    /* Do something with data */

    /* Free memory */
    sqlite3_free_table(result)



id|value
1|eenie
2|meenie
3|miny
4|mo
5|moo

Thanks to anyone who can help me..

Edited 4 Years Ago by pritaeas: Moved.

Agreed, but it has still been maintained, so it still should work.

I get an error message saying that 'the size of result can't be determined'.

That's because you declared it with unspecified array size on line 5 and that's illegal in c++. Change it to this: char **result = NULL;

Edited 4 Years Ago by Ancient Dragon

This article has been dead for over six months. Start a new discussion instead.