Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Linux2022Fall
# Linux2022Fall

># :heart:***教授好帥***

![](swanbaola.gif)
1 change: 1 addition & 0 deletions f74104757/lab_2_git/first.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
first text
9 changes: 9 additions & 0 deletions lab_5_F74104757/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore the build and lib dirs
build
lib/*

# Ignore any executables
bin/*

# Ignore temporary files
*.swp
30 changes: 30 additions & 0 deletions lab_5_F74104757/Makefile
Original file line number Diff line number Diff line change
@@ -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)

6 changes: 6 additions & 0 deletions lab_5_F74104757/include/strcpy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef STRCPY_H
#define STRCPY_H

char *sstrcpy(char *dest, const char *src);

#endif /* STRCPY_H */
11 changes: 11 additions & 0 deletions lab_5_F74104757/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
#include "../include/strcpy.h"
int main()
{
const char *src = "f74104757";
char *dest = malloc(10);
dest = sstrcpy(dest, src);
printf("%s\n", dest);
return 0;
}
10 changes: 10 additions & 0 deletions lab_5_F74104757/src/strcpy.c
Original file line number Diff line number Diff line change
@@ -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;
}
Binary file added swanbaola.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.