c++ - 如何更改控制台上的特定线条颜色?使用最新的 IDE 在 C 中编码时。如果我使用系统(“颜色”)而不是整个前景色变化
问题描述
This code is used to select menu options using the up & down arrow
key but I want the output line in the arrowhere function as coloured
and output lines in menu function should be different in colour
on Console as compared to the line of function arrowhere
void menu()
{
system("cls");
int position = 1;
int keypress = 0;
while (keypress != 13) Counter Char Key Enter Is Set
{
system("cls");
arrowhere(1, position);
printf("Addition\n"); Its color will be remain default such that white
arrowhere(2, position);
printf("Subtraction\n"); Its color will be remain default such that white
arrowhere(3, position);
printf("Exit\n"); Its color will be remain default such that white
keypress = getch();
if (keypress == 80 && position != MAX) To check down key
{
position++;
}
else if (keypress == 72 && position != MIN)To Check Upper Key
{
position--;
}
else
{
position = position;If any other key except Enter is pressed than position is not affected
}
}
}
void arrowhere(int realposition, int arrowposition) 输出与菜单功能中存在的列表相邻的箭头位置。
{
if (realposition == arrowposition)
{
printf("--->> - "); 我只想将这条线的颜色更改为蓝色,这个箭头出现在菜单选项旁边,请参见 Menu() 函数。}
}
解决方案
推荐阅读
- c# - ASP.NET 核心 MVC。Stripe.StripeException:'没有这样的费用:'txn_1HewOXGhhS4IDSpp9ifQ6hYq''
- c - 这个代码结果是什么?为什么会这样?
- bash - 如何将 wpa_cli 写入文本文件
- cmake - 在 GitHub Actions 中缓存通过 CMake FetchContent 获取的源代码
- ios - CarPlay 中未显示 MyApp
- if-statement - mit-scheme 中的多个 if 语句
- php - 如何在 Laravel 8.0 中自定义登录文件名?
- pattern-matching - ReasonML 记录模式匹配的正确方法
- xml - 除了使用扩展之外,如何在 XSLT 中处理自定义命名空间?
- python - Odoo 10 收到自定义电子邮件模板渲染错误