Solved

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

Posted on 2004-08-23
7
1,148 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
7 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 25 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 25 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now