I have a C program that prints out two lines as follows:
Line 1
Line 2
What I would like is for this program to sleep for one second, and then
print out two more lines, overwriting the previous two. The sleeping bit
is trivial but, what about the overwriting? I am assuming that the output
will be displayed on a standard terminal emulator, like xterm. 11 5529
In article <pa************ *************** @sjones.org>,
Steven Jones <sj****@sjones. org> wrote: I have a C program that prints out two lines as follows:
Line 1 Line 2
What I would like is for this program to sleep for one second, and then print out two more lines, overwriting the previous two. The sleeping bit is trivial but, what about the overwriting? I am assuming that the output will be displayed on a standard terminal emulator, like xterm.
Allow me to be the first to say this - and I say it from the deepness of my
heart, with all the kindness and love one has come to associate with the
helpful posts you get in this newsgroup:
Not portable. Can't discuss it here. Blah, blah, blah.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Steven Jones wrote: I have a C program that prints out two lines as follows:
Line 1 Line 2
What I would like is for this program to sleep for one second, and then print out two more lines, overwriting the previous two. The sleeping bit is trivial but, what about the overwriting? I am assuming that the output will be displayed on a standard terminal emulator, like xterm.
printf("\r"); fflush(stdout);
But, while this will work on most any display device (including hard copy
devices), it is likely to leave output in a mess on most of them.
- --
Lew Pitcher
IT Specialist, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group
(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
iD8DBQFD8IgYagV FX4UWr64RAlVaAJ sHIcbBegJsQf1pu 669WsBbpAy1lwCg 7RBb
bdLqgwKLNM3qDtT vOeU10Vc=
=tvu6
-----END PGP SIGNATURE-----
Steven Jones wrote: I have a C program that prints out two lines as follows:
Line 1 Line 2
What I would like is for this program to sleep for one second, and then print out two more lines, overwriting the previous two. The sleeping bit is trivial but, what about the overwriting? I am assuming that the output will be displayed on a standard terminal emulator, like xterm.
As already mentioned, this is off topic in this newsgroup. You might
want to have a look at the NCURSES library.
August
--
I am the "ILOVEGNU" signature virus. Just copy me to your
signature. This email was infected under the terms of the GNU
General Public License.
August Karlstrom wrote: Steven Jones wrote:
I have a C program that prints out two lines as follows:
Line 1 Line 2
What I would like is for this program to sleep for one second, and then print out two more lines, overwriting the previous two. The sleeping bit is trivial but, what about the overwriting? I am assuming that the output will be displayed on a standard terminal emulator, like xterm.
As already mentioned, this is off topic in this newsgroup. You might want to have a look at the NCURSES library.
The question seems entirely topical: "How can I do _X_
in C?" As it happens, the answer is either "You cannot"
(for strict constructionist s) or "You need facilities that
are not part of C, but may be available as extensions on
the platforms that interest you" (for people of a helpful
bent). An *extremely* helpful person might even suggest a
look at Questions 19.3 and 19.4 in the comp.lang.c Frequently
Asked Questions (FAQ) list at http://c-faq.com/ -- but that's
*really* going too far, and anyone who did so would be rightly
castigated.
See also "praeteriti on."
--
Eric Sosman es*****@acm-dot-org.invalid
Lew Pitcher wrote: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Steven Jones wrote: I have a C program that prints out two lines as follows:
Line 1 Line 2
What I would like is for this program to sleep for one second, and then print out two more lines, overwriting the previous two. The sleeping bit is trivial but, what about the overwriting? I am assuming that the output will be displayed on a standard terminal emulator, like xterm.
printf("\r"); fflush(stdout);
But, while this will work on most any display device (including hard copy devices), it is likely to leave output in a mess on most of them.
Given that he wants to overwrite both lines with two new lines[*], the
above solution won't work.
This comes down to the need to use some sort of extension, perhaps the
curses library, in order to do it. The use of curses (or any other
library which may perform this function) is OT in clc. I'm not sure
where curses is topical.
[*] As opposed to "two newlines". :-)
--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer .h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th***** ********@gmail. com>
On Mon, 13 Feb 2006 13:02:44 +0000, Steven Jones wrote: I have a C program that prints out two lines as follows:
Line 1 Line 2
What I would like is for this program to sleep for one second, and then print out two more lines, overwriting the previous two. The sleeping bit is trivial but, what about the overwriting? I am assuming that the output will be displayed on a standard terminal emulator, like xterm.
You guys are right: This is off-topic in this group. I realized shortly
after posting; my apologies. Anyway, in case anyone is interested, on an
xterm terminal emulator the effect can be achieved with
printf("\x1b[2A") ;
just before (or after) the sleep() call.
Steven Jones wrote: On Mon, 13 Feb 2006 13:02:44 +0000, Steven Jones wrote:
I have a C program that prints out two lines as follows:
Line 1 Line 2
What I would like is for this program to sleep for one second, and then print out two more lines, overwriting the previous two. The sleeping bit is trivial but, what about the overwriting? I am assuming that the output will be displayed on a standard terminal emulator, like xterm.
You guys are right: This is off-topic in this group. I realized shortly after posting; my apologies. Anyway, in case anyone is interested, on an xterm terminal emulator the effect can be achieved with
printf("\x1b[2A") ;
just before (or after) the sleep() call.
Whatever an "xterm emulator" may be, that code won't work unless
the destination falls in the class of ANSI standard CRT terminals
(which are OT here). These are only one of many possible terminal
types, and are the reason why such things as termtype and curses
(both also OT here) were invented.
--
"The power of the Executive to cast a man into prison without
formulating any charge known to the law, and particularly to
deny him the judgement of his peers, is in the highest degree
odious and is the foundation of all totalitarian government
whether Nazi or Communist." -- W. Churchill, Nov 21, 1943
Steven Jones wrote: On Mon, 13 Feb 2006 13:02:44 +0000, Steven Jones wrote:
I have a C program that prints out two lines as follows:
Line 1 Line 2
What I would like is for this program to sleep for one second, and then print out two more lines, overwriting the previous two. The sleeping bit is trivial but, what about the overwriting? I am assuming that the output will be displayed on a standard terminal emulator, like xterm. You guys are right: This is off-topic in this group.
As Eric Sosman said, the question is on topic, it's just that the answer
is that you need something beyond standard C.
I realized shortly after posting; my apologies. Anyway, in case anyone is interested, on an xterm terminal emulator the effect can be achieved with
printf("\x1b[2A") ;
just before (or after) the sleep() call.
For increased portability look at the various screen handling libraries
such as Curses as others have suggested.
--
Flash Gordon
Living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidlines and intro - http://clc-wiki.net/wiki/Intro_to_clc
On Mon, 13 Feb 2006 13:02:44 GMT, in comp.lang.c , Steven Jones
<sj****@sjones. org> wrote: I have a C program that prints out two lines as follows:
Line 1 Line 2
What I would like is for this program to sleep for one second, and then print out two more lines, overwriting the previous two. The sleeping bit is trivial but, what about the overwriting? I am assuming that the output will be displayed on a standard terminal emulator, like xterm.
This is a FAQ - search for entries relating to in-situ altering of
files - but essentially you can't do this in standard C.
Mark McIntyre
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =---- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Darren Dale |
last post by:
Is there a module somewhere that intelligently deals with reports to the
command line? I would like to report the progress of some pretty lengthy
simulations, and currently I have the new reports written on a new line
rather rather than overwriting the previous report.
Thanks,
Darren
|
by: Edd Dawson |
last post by:
Hi. I have a strange problem involving the passing of command line
arguments to a C program I'm writing. I tried posting this in
comp.programming yesterday but someone kindly suggested that I'd have
better luck here. So here goes!
My program ignores any command line arguments, or at least it's
supposed to. However, when I pass any command line arguments to the
program, the behaviour of one of the functions changes mysteriously. I
have...
|
by: tweak |
last post by:
I have been messing around with buffers, and
I found it peculiar that the code below will
run without a segmentation fault.
As far as I know, overwriting the allocated space
from a call to malloc() results in undefined
behavior.
Any ideas why overwriting the dynamically
assigned space doesn't cause a segmentation
|
by: Joe Delphi |
last post by:
Hi
Newbie to VB.Net and I have a question
I need to open a text file, read each line, and if I find something in
the line, delete that line from the text file. Can anyone tell me how to
do this. Some of my code is below:
Try
FileOpen(254, "FormSettings.ini", OpenMode.Input)
|
by: Jamiil |
last post by:
JavaScipt
~~~~~~~
<script type="text/javascript">
name = new String("My Name");
document.write("<H4>Author: </H4>" + name);
</script>
I would like the word 'Author:' to be in 4th level heading and the name
variable value to be displayed in regular font, I get that but in two
lines. What can I do to get the browser to display the two values in
| |
by: News |
last post by:
Hi Everyone,
The attached code creates client connections to websphere queue managers
and then processes an inquiry against them.
The program functions when it gets options from the command line.
It also works when pulling the options from a file.
|
by: tomtown.net |
last post by:
Hello
I'm trying to get a single line removed from a text file using a search
pattern (pretty simple: if line contains "NODE1") -> remove line). To
achieve this I's like to operate with only the original file and no
temp file since the file is 1. on a network resource 2. pretty big 3.
accessed by plenty of clients. Copying the file or reading everything
into an array and then writing it back using the StreamWriter would
lock the file...
|
by: dave2071 |
last post by:
Hi
I am having trouble trying to get the line number for a node from an XML DOM document. Xerces-J has a good example by extending the DOMParser and overwriting the startDocument and startElement methods but this is done using Xerces own library paths. Does anyone know or can give me a pointer on how to do this using regular Java API ?
Thanks, Dave
|
by: Jason |
last post by:
Hi,
I need to open an existing file, seek to a position at X number of
bytes, and write out Y number of bytes overwriting any existing bytes,
but no erasing any other data. Is this possible?
I've opened a file in append "a" mode, and then used fseek with
SEEK_SET to seek to 0 bytes into the file, but this sets the position
at the end of existing data, not actually at the start of the file.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |