There is a code snippet:
char *dbname = valueOfParam("dbname"); char *dbuser = valueOfParam("dbuser"); char *dbpass = valueOfParam("dbpass"); char *conninfo; // Then I try compile new variable like this: printf("PQconnectdb(\"dbname=%s host=localhost user=%s password=%s\");", dbname, dbuser, dbpass); // But I need create the variable sprintf(conninfo, "PQconnectdb(\"dbname=%s host=localhost user=%s password=%s\");", dbname, dbuser, dbpass); How to allocate memory for conninfo ? Indeed, without allocating the required amount of memory, the code is incorrect.
man asprintfsomething. And all the participants of this cozy chat. - 0andriy