gotoxy() function is not working in Visual Studio

你。 提交于 2019-12-31 07:12:10

问题


I'm not able to use gotoxy() function in Visual Studio 2010. Is there any alternative for that?


回答1:


Are you talking about command line applications or windows applications? You must remember that VC2008 is a windows specific development environment, so if you were learning programming on a linux/unix or an older dos system then things will not be the same.

The only way I know of under windows to change the position of the cursor in a console application is to use the windows function SetConsoleCursorPositon.

http://msdn.microsoft.com/es-es/library/windows/desktop/ms686025(v=vs.85).aspx

I hope this helps you!




回答2:


gotoxy() is not part of standard C++ but is was part of <conio.h> which is a non-standard header and shipped with the runtime library.

If the latest runtime doesn't support this function (unlikely, they are usually backwardly compatible) you can link your code against an older version of the runtime library, with the appropriate headers.

My guess is that the function has not been dropped so I question why you think you can't use it.




回答3:


Try using SetConsoleCursorPositon function




回答4:


gotoxy(); is include in <conio.h> but only in OLD(REALLY OLD) such as "Turbo C"....if you are using "Microsoft Visual", use thi

void gotoxy(int x, int y)
{
    COORD c = { x, y };  
    SetConsoleCursorPosition(  GetStdHandle(STD_OUTPUT_HANDLE) , c);
}

and use #include<windows.h>

and don't forget to mention the prototype declaration...

Hope this helps...Cheers!!



来源:https://stackoverflow.com/questions/13706439/gotoxy-function-is-not-working-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!