From 69d7472e288555b6dcc8bf821fc0cd68b277ce0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=A4=A7=E4=BB=99?= <1900919313@qq.com> Date: Sat, 17 Aug 2024 14:49:18 +0800 Subject: [PATCH] c --- docs/notes/01_c-basic/03_xdx/index.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/notes/01_c-basic/03_xdx/index.md b/docs/notes/01_c-basic/03_xdx/index.md index 77f8e10..e237074 100644 --- a/docs/notes/01_c-basic/03_xdx/index.md +++ b/docs/notes/01_c-basic/03_xdx/index.md @@ -1019,7 +1019,9 @@ int main() { #include int main() { - + // 禁用 stdout 缓冲区 + setbuf(stdout, NULL); + // 使用整型来表示真和假两种状态 int handsome = 0; printf("帅不帅[0 丑,1 帅]: "); @@ -1052,7 +1054,9 @@ int main() { #define FALSE 0 int main() { - + // 禁用 stdout 缓冲区 + setbuf(stdout, NULL); + BOOL handsome = 0; printf("帅不帅[FALSE 丑,TRUE 帅]: "); scanf("%d", &handsome); @@ -1078,12 +1082,17 @@ int main() { ```c #include - int main() { + // 禁用 stdout 缓冲区 + setbuf(stdout, NULL); + int temp; // 使用 int 类型的变量临时存储输入 _Bool handsome = 0; printf("帅不帅[0 丑,1 帅]: "); - scanf("%d", &handsome); + scanf("%d", &temp); + + // 将输入值转换为 _Bool 类型 + handsome = (temp != 0); if (handsome) { printf("你真的很帅!!!");