954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

clrscr(); and gotoxy();

Please help me how to use clrscr(); and gotoxy(); functions in other C Compilers?

playagain
Newbie Poster
4 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

Please read this thread . posted a couple days ago

gotoxy is a borland-specific function which was never implemented by any other compiler. If you want to use it with other compilers you will have to write your own gotoxy() function using operating system specific api calls.

Ancient Dragon
Retired & Loving It
Team Colleague
30,050 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

if you are using visual C++ it is very simple to write your own functions.

// function definition -- requires windows.h

void gotoxy(int x, int y)
{
HANDLE hConsoleOutput;
COORD dwCursorPosition;
cout.flush();
dwCursorPosition.X = x;
dwCursorPosition.Y = y;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition);
}

// function definition -- requires process.h
void clrscr()
{
system("cls");
}

guy40az
Junior Poster in Training
57 posts since Mar 2007
Reputation Points: 10
Solved Threads: 2
 

How if I'm using Dev-C++

playagain
Newbie Poster
4 posts since May 2007
Reputation Points: 10
Solved Threads: 0
 

>// function definition -- requires process.h
The only header needed for that function is .

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

in DEV C++


#include

void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_H ANDLE), coord);
}

the clrscr function should work

guy40az
Junior Poster in Training
57 posts since Mar 2007
Reputation Points: 10
Solved Threads: 2
 

write a name and birthplace and birthday in gotoxy turbo c++

karrl
Newbie Poster
1 post since Jun 2010
Reputation Points: 9
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You