eclipse - Raspberry PI 2 - How to get file-access for c-program to write on disc -
i using raspbian on rpi2 , tried create/change sqlite database c-program.
here little bit code:
static sqlite3 *db; static char *zerrmsg = 0; //.... sqlite3_open(path_database, &db); char *sql_statement = "create table if not exists mytable (datetime bigint, myval bigint)"; sqlite3_exec(db,sql_statement, null, null, &zerrmsg); sqlite3_close(db); as ide use eclipse cdt.
in eclipse debug-mode , executing program double click (in "sudo startx" mode), raspbian creates me database file.
if start program via terminal (sudo /home/pi/test/myprogram) no database-file created.
folder "test" , executable "myprogram" have both chmod 755 access. searched lot, found nothing helps me.
each 1 of sqlite3 functions returns error code. after every call, check error code sqlite_ok. if isn't, function failed, , need handle error.
you can call sqlite3_errstr convert error code string.
for more information error handling in sqlite3, see https://www.sqlite.org/c3ref/errcode.html .
Comments
Post a Comment