• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

display an item at a specific location

In C, how do I print something at a specific location?

I want XXX to be displayed on the current line(not named), at row 22.  
  • 2
1 Solution
Which OS? If it is Windows then use TextOut()
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.
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)
    gotoxy(35, 12);
    cprintf("Hello world");
    return 0;
Borland C++ 5.0 Programmer's Guide
I hope, it helps. Alex
>> 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().
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now