Solved

display an item at a specific location

Posted on 2000-04-07
4
183 Views
Last Modified: 2010-04-02
In C, how do I print something at a specific location?
eg;
printf("XXX");

I want XXX to be displayed on the current line(not named), at row 22.  
0
Comment
Question by:sima1980
  • 2
4 Comments
 
LVL 8

Expert Comment

by:gelbert
ID: 2694428
Which OS? If it is Windows then use TextOut()
0
 
LVL 22

Expert Comment

by:nietod
ID: 2694475
Standard C++ provides no features for controling how output is displayed.  In fact, standard C++ doesn't even assume that the output is going to am monitor,  It coudl be going to a file, a com device, etc.  So you have to resort to OS-specific and/or hardware-specific techniques to do this.

That is why we need to know what OS this is for--like gelbert asked.

If this is for a windows console program, you want to use WriteConsole() to do this.  You also might want to see if your compiler has the non-stadnard gotoxy() function in its library.  it is not part of standard C++, but many compilers do include it.
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 50 total points
ID: 2695824
Most of compliers support
gotoxy(x,y) function. (But , of cource, not Win32 GUI!). Next is an example:
/* gotoxy example */

#include <conio.h>

int main(void)
{
    clrscr();
    gotoxy(35, 12);
    cprintf("Hello world");
    getch();
    return 0;
}
Borland C++ 5.0 Programmer's Guide
I hope, it helps. Alex
0
 
LVL 22

Expert Comment

by:nietod
ID: 2695926
>> Most of compliers support
I wouldn't say most.  I would say "Borland".  I don't know of any non-borland C/C++ compiler that supports gotoxy().
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

726 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