C++/SQLite only outputting one row of data

2019-03-04 02:22发布

I'm having an issue where only one of my 5 test rows will output in C++. My code is:

#include <cstdio>
#include <sqlite3.h>
#include <windows.h>
#include <wincrypt.h>
#include <string>
#include <vector>
#include <iostream>

using namespace std;
/*Definitions*/
sqlite3 *db;
void *arg;
char *err;
const char* stmt = "SELECT * from table";
/*End of Definitions*/

int exec(void *arg, int argc, char **argv, char **column) {
    int i;
    for(i = 0; i < argc; i++) {
        cout << column[i] << ": " << argv[i] << endl;
    }
    cout << "------" << endl;
}

int main() {
    int rc = sqlite3_open("test.sqlite", &db); /*Open db "test.sqlite"*/
    if(!rc) {
        while(true) {
            sqlite3_exec(db, stmt, exec, arg, &err);
            if(err) {
                break;
            }
        }
    }
    /*Ending Stuffz (NOTHING BEYOND THIS POINT)*/
    cin.get();
    return 0;
}

I am not getting any errors; it is purely just outputting the first row. Any help is appreciated, thanks.

0条回答
登录 后发表回答