feat: add sprintf

This commit is contained in:
dancingCycle 2023-01-18 15:06:39 +01:00
parent e215b283f4
commit daebcb8ce8
2 changed files with 56 additions and 0 deletions

23
sprintf/main.c Normal file
View File

@ -0,0 +1,23 @@
/*use sleep*/
#include <unistd.h>
/*use printf*/
#include <stdio.h>
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;
}

33
sprintf/makefile Normal file
View File

@ -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 *~