?
Solved

gotoxy() and clrscr() not working in Mic visual c++

Posted on 2004-08-23
7
Medium Priority
?
1,222 Views
Last Modified: 2013-12-14
In the past i have always used boreland c++, i am now using Microsoft visual c++, i have created a new project and a "win console app". In my cpp file i am trying to use the gotoxy() function and the clrscr() function, but the complier does not recognise these functions! why is this? Do i need to add these function via a library? if so how, i have the following includes

#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
#include <string.h>
#include <dos.h>
#include <ctype.h>
#include <conio.h>

but it still does not recognise the above functions.

cheers,

Jim
0
Comment
Question by:jamesmcskeane
  • 3
4 Comments
 
LVL 19

Expert Comment

by:mrwad99
ID: 11869458
To set the cursor position in VC++, you need, for example:

#include <windows.h>
#include <stdio.h>

HANDLE hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );

    if ( hConsole != INVALID_HANDLE_VALUE )
        {
        COORD pos = {32, 11};
        SetConsoleCursorPosition ( hConsole, pos );
        printf ( "Hello World!\n" );
        }

gotoxy() does not work in VC++.
0
 
LVL 19

Accepted Solution

by:
mrwad99 earned 100 total points
ID: 11869467
...and to clear the screen, read http://www.mvps.org/vcfaq/lang/7.htm
1
 
LVL 17

Assisted Solution

by:rstaveley
rstaveley earned 100 total points
ID: 11875911
If you don't want to change your spots, you might want to grab the functions from http://www.codeguru.com/Cpp/W-D/console/article.php/c3959/
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 12091159
Split points between rstaveley and myself.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question