Solved

display an item at a specific location

Posted on 2000-04-07
4
179 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
Comment Utility
Which OS? If it is Windows then use TextOut()
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
Comment Utility
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
Comment Utility
>> 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now