feat: adjust sprintf
This commit is contained in:
parent
daebcb8ce8
commit
9c5776b620
|
@ -6,18 +6,24 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
/*'postgresql://begerad:secret@localhost:5432/sib00_vbn_gtfs'*/
|
||||
/*declaration*/
|
||||
int cx;
|
||||
int port = 5432;
|
||||
char * user = "begerad";
|
||||
char * secret = "secret";
|
||||
char * host = "localhost";
|
||||
char * db = "vbn_data";
|
||||
char pqConInfo[100];
|
||||
const int pqConInfoSize = 100;
|
||||
char pqConInfo[pqConInfoSize];
|
||||
|
||||
printf("main() Started...\n");
|
||||
|
||||
sprintf(pqConInfo,"postgresql://%s:%s@%s:%d/%s",user,secret,host,port,db);
|
||||
printf("main() pqConInfo: %s\n",pqConInfo);
|
||||
cx = snprintf(pqConInfo,pqConInfoSize,"postgresql://%s:%s@%s:%d/%s",user,secret,host,port,db);
|
||||
if(cx>=0 && cx<pqConInfoSize){
|
||||
printf("main() pqConInfo: %s\n",pqConInfo);
|
||||
printf("main() cx: %d\n",cx);
|
||||
}else{
|
||||
fprintf(stderr,"main() error creating pqConInfo\n");
|
||||
}
|
||||
printf("main() Done.\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ EXE = main
|
|||
|
||||
# Compiler, Linker Defines
|
||||
CC = /usr/bin/gcc
|
||||
CFLAGS = -ansi -pedantic -Wall -O2
|
||||
CFLAGS = -Wall
|
||||
LIBPATH = -L.
|
||||
LDFLAGS = -o $(EXE) $(LIBPATH) $(LIBS)
|
||||
CFDEBUG = -ansi -pedantic -Wall -g -DDEBUG $(LDFLAGS)
|
||||
|
|
Loading…
Reference in New Issue