#include <stdio.h>
#include <stdlib.h>
#include <postgresql/libpq-fe.h>

int main(int argc, char **argv)
{
const char *conninfo;
const char *serverversion;
PGconn *conn;
const char *paramtext = "server_version";
conninfo = "hostaddr = 127.0.0.1 dbname = test user = earl password = bigshot";

conn = PQconnectdb(conninfo);
if ( PQstatus(conn) != CONNECTION_OK )
{

printf("Unable to establish connection: %s",PQerrorMessage(conn));
return 1;
}
else
{
printf("Connection established!\n");
serverversion = PQparameterStatus(conn,paramtext);
printf("Server Version: %s\n",serverversion);
}
PQfinish(conn);
return 0;
}
Copyright © 2009,  2010,  2011,  2012,  2013, 2014     BeautifulWork Project    e-mail:  ahiliation@yahoo.co.in
BeautifulWork Project comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.