gpt4 book ai didi

c - 在 C 中为用户输入添加下划线

转载 作者:行者123 更新时间:2023-11-30 15:58:42 27 4
gpt4 key购买 nike

下面是该程序的示例运行,假设可执行文件名为 match 和 hit。这次运行说明了人类玩家赢得游戏的情况。用户输入是加粗。

/home/userXYZ/ECE15/Lab3> match_and_hit
Welcome to the MATCH and HIT game
The computer has selected a 4-digit number.
Try to deduce it in 12 rounds of queries.

Round #1
Please enter your query (4 digits): 5341 <---(this number should be underlined)

......

我不知道如何在用户输入下划线。任何帮助将不胜感激。

最佳答案

假设您的终端支持 ANSI 转义序列,您可以使用:

#define ANSI_UNDERLINED_PRE  "\033[4m"
#define ANSI_UNDERLINED_POST "\033[0m"

printf(ANSI_UNDERLINED_PRE "underlined" ANSI_UNDERLINED_POST "\n");

关于c - 在 C 中为用户输入添加下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9559850/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com