From daebcb8ce89a310789e71365b6f2df1b388dfad2 Mon Sep 17 00:00:00 2001 From: "Begerad, Stefan" Date: Wed, 18 Jan 2023 15:06:39 +0100 Subject: [PATCH] feat: add sprintf --- sprintf/main.c | 23 +++++++++++++++++++++++ sprintf/makefile | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 sprintf/main.c create mode 100644 sprintf/makefile diff --git a/sprintf/main.c b/sprintf/main.c new file mode 100644 index 0000000..35df1d0 --- /dev/null +++ b/sprintf/main.c @@ -0,0 +1,23 @@ +/*use sleep*/ +#include + +/*use printf*/ +#include + +int main() +{ + /*'postgresql://begerad:secret@localhost:5432/sib00_vbn_gtfs'*/ + int port = 5432; + char * user = "begerad"; + char * secret = "secret"; + char * host = "localhost"; + char * db = "vbn_data"; + char pqConInfo[100]; + + printf("main() Started...\n"); + + sprintf(pqConInfo,"postgresql://%s:%s@%s:%d/%s",user,secret,host,port,db); + printf("main() pqConInfo: %s\n",pqConInfo); + printf("main() Done.\n"); + return 0; +} diff --git a/sprintf/makefile b/sprintf/makefile new file mode 100644 index 0000000..f4070c9 --- /dev/null +++ b/sprintf/makefile @@ -0,0 +1,33 @@ +# Source, Executable, Includes, Library Defines +INCL = +SRC = main.c +OBJ = $(SRC:.c=.o) +LIBS = +EXE = main + +# Compiler, Linker Defines +CC = /usr/bin/gcc +CFLAGS = -ansi -pedantic -Wall -O2 +LIBPATH = -L. +LDFLAGS = -o $(EXE) $(LIBPATH) $(LIBS) +CFDEBUG = -ansi -pedantic -Wall -g -DDEBUG $(LDFLAGS) +RM = /bin/rm -f + +# Compile and Assemble C Source Files into Object Files +%.o: %.c + $(CC) -c $(CFLAGS) $*.c + +# Link all Object Files with external Libraries into Binaries +$(EXE): $(OBJ) + $(CC) $(LDFLAGS) $(OBJ) + +# Objects depend on these Libraries +$(OBJ): $(INCL) + +# Create a gdb/dbx Capable Executable with DEBUG flags turned on +debug: + $(CC) $(CFDEBUG) $(SRC) + +# Clean Up Objects, Exectuables, Dumps out of source directory +clean: + $(RM) $(OBJ) $(EXE) core a.out *.csv *~