返回PGconn结构类型" postgresql结构类型"指针在C中

时间:2016-03-09 00:20:34

标签: c postgresql pg

我有这样的功能,以便连接到Postgresql数据库:

PGconn *connect()
{
    PGconn *conn;

    //Creating a connection to database
    conn = PQconnectdb("dbname=... host=... user=... password=...");
    //Check connection status
    if (PQstatus(conn) == CONNECTION_BAD) {
        printf("We were unable to connect to the database\n");
        return 0;
    }

    return conn;
}

我想回归" conn"值,但我得到分段错误错误。我怎样才能回复" conn"这里有价值吗?

0 个答案:

没有答案