介绍
在本实验中,你将学习如何编写一个 C 程序来反转给定的字符串。该程序将从用户处获取输入,反转字符串并将结果输出到控制台。这个概念可以用于检查一个字符串是否是回文,因为回文字符串在反转后仍然具有相同的值。
注意:你需要自己创建文件 ~/project/main.c
来练习编码,并学习如何使用 gcc 编译和运行它。
cd ~/project
## 创建 main.c
touch main.c
## 编译 main.c
gcc main.c -o main
## 运行 main
./main
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
c(("`C`")) -.-> c/BasicsGroup(["`Basics`"])
c(("`C`")) -.-> c/ControlFlowGroup(["`Control Flow`"])
c(("`C`")) -.-> c/CompoundTypesGroup(["`Compound Types`"])
c(("`C`")) -.-> c/UserInteractionGroup(["`User Interaction`"])
c/BasicsGroup -.-> c/variables("`Variables`")
c/ControlFlowGroup -.-> c/for_loop("`For Loop`")
c/ControlFlowGroup -.-> c/while_loop("`While Loop`")
c/CompoundTypesGroup -.-> c/strings("`Strings`")
c/UserInteractionGroup -.-> c/user_input("`User Input`")
c/UserInteractionGroup -.-> c/output("`Output`")
subgraph Lab Skills
c/variables -.-> lab-123323{{"`反转字符串程序`"}}
c/for_loop -.-> lab-123323{{"`反转字符串程序`"}}
c/while_loop -.-> lab-123323{{"`反转字符串程序`"}}
c/strings -.-> lab-123323{{"`反转字符串程序`"}}
c/user_input -.-> lab-123323{{"`反转字符串程序`"}}
c/output -.-> lab-123323{{"`反转字符串程序`"}}
end