Find out yourself :-)
If you are using gcc, add -g flag when compiling, and then run it using gdb:
gdb your-executable
and then
> run
and then when it give the seg-fault, run:
> backtrace
This will give you a good hint about what is wrong.
Ran
On 4/6/06, 杰 张 <[EMAIL PROTECTED]> wrote:
>
> Hi all,
> I just want to get the values of a table.The result implemented is
> "Open OK!
> segmentation fault ". Why did I got this result ? The following is my
> code:
>
> #include <stdio.h>
> #include <string.h>
> #include "sqlite3.h"
> main()
> {
> char **errmsg;
> int ret;
> int rc;
> sqlite3 *db;
> char *sql = "SELECT * FROM light;";
> char ***resultp;
> int *nrow;
> int *ncolumn;
> ret = sqlite3_open("sensor.db",&db);
> if (ret)
> {
> fprintf(stderr, "Could not open database:%s\n",
> sqlite3_errmsg(db));
> exit (1);
> }
> else
> { printf("Open OK!\n");
> rc = sqlite3_get_table(db,sql,resultp,nrow,ncolumn,errmsg);
> printf("rc=%d\n",rc);
> if (rc)
> {
> fprintf(stderr,"can't open the
> table:%s\n",sqlite3_errmsg(db));
> exit(1);
> }
> else printf("open the table ok");
> }
>
> sqlite3_close(db);
> printf("Close OK!");
> }
>
> Thank you so much!
>
> zhangjie
>
>
>
> ---------------------------------
> 雅虎1G免费邮箱百分百防垃圾信
> 雅虎助手-搜索、杀毒、防骚扰
>