Solved

display an item at a specific location

Posted on 2000-04-07
4
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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++.

696 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