From 90794b46531112f59208c53b0ab3309b3ef10289 Mon Sep 17 00:00:00 2001 From: elsonkong0212 Date: Fri, 23 Sep 2022 01:20:29 +0800 Subject: [PATCH 1/2] Add F74101335 --- f74101335/lab_2_git/first.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 f74101335/lab_2_git/first.txt diff --git a/f74101335/lab_2_git/first.txt b/f74101335/lab_2_git/first.txt new file mode 100644 index 00000000..38181e50 --- /dev/null +++ b/f74101335/lab_2_git/first.txt @@ -0,0 +1 @@ +first text From 0efd4ecae9302e3af9168d56ae54689c71cf080a Mon Sep 17 00:00:00 2001 From: elsonkong0212 Date: Fri, 14 Oct 2022 01:34:26 +0800 Subject: [PATCH 2/2] Lab-5 --- lab_5_F74101335/.gitignore | 9 +++++++++ lab_5_F74101335/Makefile | 29 +++++++++++++++++++++++++++++ lab_5_F74101335/include/strcpy.h | 6 ++++++ lab_5_F74101335/src/main.c | 10 ++++++++++ lab_5_F74101335/src/strcpy.c | 12 ++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 lab_5_F74101335/.gitignore create mode 100644 lab_5_F74101335/Makefile create mode 100644 lab_5_F74101335/include/strcpy.h create mode 100644 lab_5_F74101335/src/main.c create mode 100644 lab_5_F74101335/src/strcpy.c diff --git a/lab_5_F74101335/.gitignore b/lab_5_F74101335/.gitignore new file mode 100644 index 00000000..4e458f02 --- /dev/null +++ b/lab_5_F74101335/.gitignore @@ -0,0 +1,9 @@ +# Ignore the build and lib dirs +build +lib/* + +# Ignore any executables +bin/* + +# Ignore temporary files +*.swp diff --git a/lab_5_F74101335/Makefile b/lab_5_F74101335/Makefile new file mode 100644 index 00000000..66d58241 --- /dev/null +++ b/lab_5_F74101335/Makefile @@ -0,0 +1,29 @@ +CC := gcc +SRCDIR := src +BUILDDIR := build +BINDIR := bin +INCDIR := include +TARGET := $(BINDIR)/runner + +SRCEXT := c +SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT)) +HEADERS := $(shell find $(INCDIR) -type f -name *.h) +OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) +CFLAGS := -O2 -Wall + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + mkdir -p $(BINDIR) + @echo "> Linking..." + $(CC) $^ -o $(TARGET) + + +$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) + mkdir -p $(BUILDDIR) + @echo "> Compiling..." + $(CC) $(CFLAGS) -c -o $@ $< + +clean: + @echo "> Cleaning..."; + $(RM) -rf $(BUILDDIR) $(TARGET) diff --git a/lab_5_F74101335/include/strcpy.h b/lab_5_F74101335/include/strcpy.h new file mode 100644 index 00000000..e7e0b37e --- /dev/null +++ b/lab_5_F74101335/include/strcpy.h @@ -0,0 +1,6 @@ +#ifndef STRCPY_H +#define STRCPY_H + +char *sstrcpy(char *dest, const char *src); + +#endif /*STRCPY_H */ diff --git a/lab_5_F74101335/src/main.c b/lab_5_F74101335/src/main.c new file mode 100644 index 00000000..003017e8 --- /dev/null +++ b/lab_5_F74101335/src/main.c @@ -0,0 +1,10 @@ +#include +#include +#include "../include/strcpy.h" +int main(){ + const char *src = "f74101335"; + char *dest = malloc(10); + dest = sstrcpy(dest, src); + printf("%s\n", dest); + return 0; +} diff --git a/lab_5_F74101335/src/strcpy.c b/lab_5_F74101335/src/strcpy.c new file mode 100644 index 00000000..5b4dc260 --- /dev/null +++ b/lab_5_F74101335/src/strcpy.c @@ -0,0 +1,12 @@ +#include "../include/strcpy.h" + +char *sstrcpy(char *dest, const char *src) +{ + //Input + int i = 0; + while(src[i] != '\0'){ + dest[i] = src[i]; + i ++; + } + return dest; +}