From the documentation:
This function opens a new database connection using the parameters taken from two NULL-terminated arrays. The first, keywords, is defined as an array of strings, each one being a key word. The second, values, gives the value for each key word.
I have never used this function in practice (as PQconnectdb()
seems simpler), but this example should work I think:
char *keywords[] = {"hostaddr", "port", "dbname", 0};
char *values[] = {"127.0.0.1", "5432", "testdb", 0};
conn = PQconnectdbParams((const char **)keywords, (const char **)values, 0);