473,390 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

beginner: console cursor movement

1) is there another way to move the cursor besides the escape sequences in win32 console applications?

2) i want to move my cursor up, or to be precise - backward. example:

my code generates this on the screen (\n meaning new line):
and my erase() function sould erase all cappital Es and replace them with a *.
all i need to know is how to get up and backward without erasing anything.

IMPORTANT : the original is not to be reprinted on the screen, everything is to remain, with only the Es substituted.

i.e. cout <<"\b" is backspace, that erases

and i tried "\v", vertical tab, but i got smth. strange.

Please help.
Feb 3 '08 #1
7 16803
9,208 Expert Mod 8TB
The stdout console is a replacement for a console typewriter that was standard equipment on computers in the 1970's when C was invented.

So, all you can do is type a line and go to the next line ort maybe go back to the start of the current line. There is no gotoxy() like in Unix.

You would have to clear the screen and re-display it.

Other than that, you need to write an actual Windows application where you do have freedom to move around as you wish.
Feb 3 '08 #2
671 Expert 512MB
As the console is OS specific, you would have to look up the Win32 API ( http://msdn2.microsoft.com/en-us/library/ms682087.aspx ).
Feb 3 '08 #3

You would have to clear the screen and re-display it.

Other than that, you need to write an actual Windows application where you do have freedom to move around as you wish.
thank you for the advice. i have some more questions:

1) the program is an exercise im working on from a book, and it needs to be written like a console program (win32 or whatever), no MFC or Visual Studio Forms (not yet at least :)
2) i'm working on Linux OpenSUSE and i'm making my code with g++ compiler. my question: how to clear the screen? My program displays graphical objects (objects are from a derived class) by calling virtual display functions, on the screen. so, i'm supposed to plot a square on the screen, and make it appear to move by rewriting the screen again, thus deleting the square, and rewriting the square on the screen, only in a different place. i can do that, but i still don't know how, because whatever i do std::cout will continue where it stopped last. how to clear the screen and make the cursor go to the beginning? and here's another problem: the Linux shell prompt is displays every time the program ends.

sorry for the HUGE post, and thank You for your time and patience.
Feb 3 '08 #4
i forgot to mention that my "graphic" objects are not graphic by nature, i defined myown classes for them
they look like


for example. I'm supposed to make that move. I know how to do it, all i need to know is how to "climb up", because the exercise states that i have to write a virtual class method that searches for a ' * ' and replaces it with ' ': so clearing the screen is not an option? objects are written using simple loops and cout <<' * '. instance data for the base class are X and Y coordinates on the console and the "graphic" object dimension. objects are diversed by their draw() function.
Feb 3 '08 #5
9,208 Expert Mod 8TB
so clearing the screen is not an option?
I don't know why you can't do that.

I mean Windows updates by a clear and repaint. There you identify a rectangle and mark it invalid. That will tigger a call to your paint function.

It's how movies work.
Feb 4 '08 #6
I did a project like this in highschool.... although I don't know how to read in a character thats already on the screen.... If I remember right it was just a matter of finding the right library to use. I wanna say Conio.h, but I havn't programmed in C++ using console graphics for about 5 years. The function you would use is a gotoxy(x,y) and it just rewrites over whatever you output after that. I wish I had my old assignments so I could tell you forsure, but they are long gone.

Another thing to look out for is that I found some of the old C++ libraries differed from a '94 version of a borland compiler and microsofts visual studios. I'll do some research and find out if I can get you an answer.
Feb 4 '08 #7
iomanip.h was the library I was thinking of, although conio.h also looks like it has functions to read from the console stream.

If you go search iomanip.h +gotoxy in google, you get a buncha posts about problems with compiling and stuff about Turbo C++ 3.0 and graphic libraries. That might have been what I was thinking with the differences in libraries, so you might have to track them down. Hope that helps.
Feb 4 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Robin Shuff | last post by:
Hi, I'm trying to limit the movement of the mouse cursor in using a VB app. The idea is to stop the cursor straying on to the second monitor of a dual screen set-up (i.e. a projector) while this...
by: Jim | last post by:
I having a difficult time here trying to figure out what to do here. I need a way to scroll through a recordset and display the results with both forward and backward movement on a web page(PHP...
by: Matthew | last post by:
Hi, how can I create a <A HREF'ed> image that, with an onclick event will cause the cursor to jump into a particularly assigned text form input field?
by: Danny | last post by:
How can I get the coordinates of the mouse cursor in Mozilla browsers as well as Opera and IE6? I'm struggling to understand how to capture mouse movement events with Mozilla/Netscape/Firefox and...
by: Amar Prakash Tripaithi | last post by:
Hi, Is there exists some function for controlling the cursor movement in C++. With control of cursor movement I mean, is there exists any function that let me to relocate the cursor as per...
by: R.A.M. | last post by:
Hello, I am trying to learn SQL Server. I need to write a trigger which deletes positions of the document depending on the movement type. Here's my code: set ANSI_NULLS ON set...
by: RedDevil | last post by:
Hi all! I'm new to java programming and I'm trying to find how to move the cursor to a specific point (right after the execution), instead of flashing at the end of the line "Press any key to...
by: garyusenet | last post by:
I have a programme written in C++, the programme is unmanaged and is an executable, i don't have any source code. I'm writing a C# program. I want to (a) start the programme minimized. (b) send...
by: mike | last post by:
I have the opportunity to rescue a project that uses a mouse to sense the relative position of a machine. The hardware is built...just needs to be programmed. Stop snickering!!! I didn't do it...I...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.