Skip to content

Commit f271775

Browse files
feat: cookbooks ready; clean c codes
1 parent 01a0686 commit f271775

100 files changed

Lines changed: 783 additions & 2025 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.log

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[1/2] Building C object CMakeFiles/ex1_dynamic_matrix.dir/ex1_dynamic_matrix.c.o
2+
[2/2] Linking C executable ex1_dynamic_matrix

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ repos:
2626
always_run: true
2727
pass_filenames: false
2828

29+
- id: validate-frontmatter
30+
name: Validate frontmatter
31+
entry: python3 scripts/validate_frontmatter.py
32+
language: system
33+
files: '^documents/.*\.md$'
34+
pass_filenames: false
35+
2936
# Check for added large files
3037
- repo: https://github.com/pre-commit/pre-commit-hooks
3138
rev: v4.5.0

code/volumn_codes/vol1/c_tutorials/01-program-structure/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

code/volumn_codes/vol1/c_tutorials/01-program-structure/ex1_multi_file/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

code/volumn_codes/vol1/c_tutorials/01-program-structure/ex1_multi_file/main.c

Lines changed: 0 additions & 13 deletions
This file was deleted.

code/volumn_codes/vol1/c_tutorials/01-program-structure/ex1_multi_file/utils.c

Lines changed: 0 additions & 13 deletions
This file was deleted.

code/volumn_codes/vol1/c_tutorials/01-program-structure/ex1_multi_file/utils.h

Lines changed: 0 additions & 7 deletions
This file was deleted.

code/volumn_codes/vol1/c_tutorials/01-program-structure/ex2_printf_format.c

Lines changed: 0 additions & 11 deletions
This file was deleted.

code/volumn_codes/vol1/c_tutorials/02A-data-types/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ cmake_minimum_required(VERSION 3.20)
22
project(lesson_02A_data_types C)
33

44
add_executable(ex1_sizeof_detective ex1_sizeof_detective.c)
5-
add_executable(ex2_integer_overflow ex2_integer_overflow.c)
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
#include <stdio.h>
21
#include <stdint.h>
2+
#include <stdio.h>
3+
// #include <stddef.h>
4+
5+
int main() {
6+
// 基本类型
7+
printf("sizeof(char) = %zu bytes\n", sizeof(char));
8+
printf("sizeof(short) = %zu bytes\n", sizeof(short));
9+
printf("sizeof(int) = %zu bytes\n", sizeof(int));
10+
printf("sizeof(long) = %zu bytes\n", sizeof(long));
11+
printf("sizeof(long long) = %zu bytes\n", sizeof(long long));
312

4-
#define PRINT_SIZEOF(type) printf("sizeof(%-15s) = %zu bytes\n", #type, sizeof(type))
13+
// 定长整数类型 (需包含 <stdint.h>)
14+
printf("sizeof(int8_t) = %zu bytes\n", sizeof(int8_t));
15+
printf("sizeof(uint8_t) = %zu bytes\n", sizeof(uint8_t));
16+
printf("sizeof(int32_t) = %zu bytes\n", sizeof(int32_t));
17+
printf("sizeof(uint32_t) = %zu bytes\n", sizeof(uint32_t));
18+
printf("sizeof(int64_t) = %zu bytes\n", sizeof(int64_t));
519

6-
int main(void)
7-
{
8-
PRINT_SIZEOF(char);
9-
PRINT_SIZEOF(short);
10-
PRINT_SIZEOF(int);
11-
PRINT_SIZEOF(long);
12-
PRINT_SIZEOF(long long);
13-
PRINT_SIZEOF(int8_t);
14-
PRINT_SIZEOF(uint8_t);
15-
PRINT_SIZEOF(int32_t);
16-
PRINT_SIZEOF(uint32_t);
17-
PRINT_SIZEOF(int64_t);
18-
PRINT_SIZEOF(size_t);
20+
// size_t 类型 (需包含<stdio.h>、 <stddef.h> 或 <stdlib.h>)
21+
printf("sizeof(size_t) = %zu bytes\n", sizeof(size_t));
1922

2023
return 0;
2124
}

0 commit comments

Comments
 (0)