Akshay G Bhardwaj
Akshay G Bhardwaj

Reputation: 339

gotoxy() function is not working in Visual Studio

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

Upvotes: 2

Views: 16695

Answers (4)

shridhar
shridhar

Reputation: 71

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!!

Upvotes: 7

Sheila
Sheila

Reputation: 31

Try using SetConsoleCursorPositon function

Upvotes: 3

CashCow
CashCow

Reputation: 31445

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.

Upvotes: 3

Martha
Martha

Reputation: 96

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!

Upvotes: 8

Related Questions