如果你的终端支持ANSI escape code,那么你可以使用ANSI escape code来移动光标,改变字体或背景颜色等的。
详情请参考
https://en.wikipedia.org/wiki/ANSI_escape_code
下面是一个简单的例子,用的是VS Code内置的Terminal
#include <stdio.h>
void clear()
{
printf("\033[H\033[J");
}
void goto_xy(int x, int y)
{
printf("\033[%d;%dH", y, x);
}
int main()
{
int number;
clear();
printf("Enter your number in the box below\n"
"+-----------------+\n"
"| |\n"
"+-----------------+\n");
goto_xy(2, 3);
scanf("%d", &number);
goto_xy(1, 5);
printf("The number is: %d\n", number);
return 0;
}
改成一行输入一个吧。
输出名字 ,输入该值。
你可以写好,最后打印成这种