Solved

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

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ standard library based binary archive format 6 98
debug as  junit test 4 81
eclipse formatting 6 90
designing in object programming 12 78
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

777 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