feat: 第一次c提交

This commit is contained in:
jinweios 2025-07-22 08:56:06 +00:00
commit 63ccd9f539
6 changed files with 54 additions and 0 deletions

15
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,15 @@
{
"configurations": [
{
"name": "编译并调试",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/output/main",
"MIMode": "gdb",
"cwd": ".",
"miDebuggerPath": "/usr/bin/gdb",
"preLaunchTask": "使用gcc编译代码",
}
],
"version": "2.0.0"
}

11
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"tasks": [
{
"type": "shell",
"label": "使用gcc编译代码",
"command": "make clean && make",
"detail": "使用make编译代码"
}
],
"version": "2.0.0"
}

18
Makefile Normal file
View File

@ -0,0 +1,18 @@
CC = gcc
CFLAGS = -g
SRC = src/main.c
OUT = output/main
all: $(OUT)
$(OUT): $(SRC)
$(CC) $(CFLAGS) $< -o $@
clean:
rm -f $(OUT)
run: $(OUT)
./$(OUT)
debug: $(OUT)
gdb ./$(OUT)

BIN
output/main Executable file

Binary file not shown.

3
src/hello.c Normal file
View File

@ -0,0 +1,3 @@
void hello() {
printf("Hello, World!\n");
}

7
src/main.c Normal file
View File

@ -0,0 +1,7 @@
#include<stdio.h>
#include "hello.c"
int main() {
hello();
return 0;
}