diff --git a/README.md b/README.md index 996e9b10..e19d9e58 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ -# Linux2022Fall \ No newline at end of file +# Linux2022Fall + +># :heart:***教授好帥*** + +![](swanbaola.gif) diff --git a/f74104757/lab_2_git/first.txt b/f74104757/lab_2_git/first.txt new file mode 100644 index 00000000..38181e50 --- /dev/null +++ b/f74104757/lab_2_git/first.txt @@ -0,0 +1 @@ +first text diff --git a/lab_5_F74104757/.gitignore b/lab_5_F74104757/.gitignore new file mode 100644 index 00000000..32eac6f6 --- /dev/null +++ b/lab_5_F74104757/.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_F74104757/Makefile b/lab_5_F74104757/Makefile new file mode 100644 index 00000000..e7b60d8d --- /dev/null +++ b/lab_5_F74104757/Makefile @@ -0,0 +1,30 @@ +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_F74104757/include/strcpy.h b/lab_5_F74104757/include/strcpy.h new file mode 100644 index 00000000..aa307ccb --- /dev/null +++ b/lab_5_F74104757/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_F74104757/src/main.c b/lab_5_F74104757/src/main.c new file mode 100644 index 00000000..f4ceeb3b --- /dev/null +++ b/lab_5_F74104757/src/main.c @@ -0,0 +1,11 @@ +#include +#include +#include "../include/strcpy.h" +int main() +{ + const char *src = "f74104757"; + char *dest = malloc(10); + dest = sstrcpy(dest, src); + printf("%s\n", dest); + return 0; +} diff --git a/lab_5_F74104757/src/strcpy.c b/lab_5_F74104757/src/strcpy.c new file mode 100644 index 00000000..64ce5dae --- /dev/null +++ b/lab_5_F74104757/src/strcpy.c @@ -0,0 +1,10 @@ +#include "../include/strcpy.h" + +char *sstrcpy(char *dest, const char *src) +{ + int i; + for(i = 0; src[i]; i++) + dest[i] = src[i]; + dest[i] = 0; + return dest; +} diff --git a/swanbaola.gif b/swanbaola.gif new file mode 100644 index 00000000..0234d624 Binary files /dev/null and b/swanbaola.gif differ