简体   繁体   English

如何使用函数 gotoxy(int x, int y)

[英]How to use function gotoxy(int x, int y)

I included cstdlib, stdlib.h, stdio.h, conio.h, iostream, and then I typed using namespace std...(bla bla bla bla), and gotoxy()...But then the red curly underline and build(loading...) and... "build failed"... Then okay, I tried many times and nothing.Can anybody (please!!) tell me what`s wrong with the code?我包括了 cstdlib、stdlib.h、stdio.h、conio.h、iostream,然后我输入了使用命名空间 std...(bla bla bla bla) 和 gotoxy()...但是然后红色卷曲下划线和构建(加载...)和...“构建失败”...然后好吧,我试了很多次都没有。有人(请!!)告诉我代码有什么问题吗? Here it is:这里是:

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cstdlib>
#include <conio.h>
using namespace std;
int main()
{
    gotoxy(20, 30);
}

I consider that THIS function is not supposed to be declared before use我认为这个函数不应该在使用前声明

By the way thank you in advance cause I`m desperate顺便说一下,提前谢谢你,因为我很绝望

For VC++ you can use SetConsoleCursorPosition() to define you own function, since gotoxy() function is not available in the standard libraries:对于 VC++,您可以使用 SetConsoleCursorPosition() 来定义您自己的函数,因为标准库中没有 gotoxy() 函数:

#include <windows.h>    
void gotoxy(int x, int y)
{
    COORD coordinate;
    coordinate.X = x;
    coordinate.Y = y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coordinate);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM