我有这样的功能,以便连接到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"这里有价值吗?