当用作 Gotoxy() 的替代方法时,ANSI 转义序列显示不正确

发布于 2025-01-12 01:13:31 字数 329 浏览 2 评论 0原文

conio.h 和 Gotoxy 不适用于我的 C 编译器。我尝试在网上搜索解决方案并发现以下内容:

void gotoxy(int x, int y)
{
    printf("\033[%d;%dH", y, x);
}

但是,它没有按预期定位光标。它仅

←[1;10H

在我尝试将 x 和 y 分别设置为 10 和 1 时显示。我找到了其他替代方案,例如使用 SetConsolePosition,但我仍然想知道使用 ANSI 转义序列是否有效。

我目前正在使用 CodeBlocks IDE。

conio.h and gotoxy does not work with my compiler for C. I tried searching for solutions on the web and found the following:

void gotoxy(int x, int y)
{
    printf("\033[%d;%dH", y, x);
}

However, it does not position the cursor as intended. It only displays

←[1;10H

when I try to set x and y to 10 and 1 respectively. I have found other alternatives like using SetConsolePosition but I would still like to know if using ANSI escape sequences would work.

I am currently using the CodeBlocks IDE.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文