LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-13-2004, 03:57 PM   #1
AMMullan
Member
 
Registered: Sep 2003
Location: United Kingdom
Distribution: Ubuntu, Arch
Posts: 438

Rep: Reputation: 30
Simple printf question


When I was programming in bash I could make a counter like the following:

Code:
while [ "${WAIT_TIME}" -gt 0 ]
do
  echo -ne "$WAIT_TIME...\r\a"
  (( WAIT_TIME -= 1 ))
  sleep 1
done
I know you can use the \r option in bash with printf but can it be used in C?
 
Old 02-13-2004, 04:07 PM   #2
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
technically yes, but you're probably looking for '\n'.
 
Old 02-13-2004, 04:45 PM   #3
AMMullan
Member
 
Registered: Sep 2003
Location: United Kingdom
Distribution: Ubuntu, Arch
Posts: 438

Original Poster
Rep: Reputation: 30
No \n is a new line, \r is a carriage return...

In the example I gave it printed 5... 4... etc one the same line, replacing the old line....

Thats what i want to do in c
 
Old 02-13-2004, 10:12 PM   #4
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Yes, you can use \r and it should do what you want it to.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu Fluxbox simple question, simple answer? generallimptoes Linux - Software 3 09-26-2005 02:03 PM
c printf question. fredgt Programming 5 09-09-2004 05:06 AM
io related question, when printf is called blackzone Programming 2 07-26-2004 05:41 AM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 09:03 PM
simple question seeking simple answer enzo250gto Linux - Newbie 1 10-27-2001 04:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration