473,395 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

printf() with control character

Hello,

I'm trying to write a rotational symbol in a CLI process, to report
activity to the user console, using printf( "%s\b", symbol ); but I see
the control character (\b) is been printed out instead of backspacing.

Is there any work around ?

Thanks in advance,

Sebastián.

May 15 '06 #1
5 2948
On 2006-05-15, Sebastian Araya <nu*****@gmail.com> wrote:
Hello,

I'm trying to write a rotational symbol in a CLI process, to report
activity to the user console, using printf( "%s\b", symbol ); but I see
the control character (\b) is been printed out instead of backspacing.

Is there any work around ?


Tried "%s\\b" or '%s\\b' already?

--
Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be>
May 15 '06 #2
Hello,

and thanks for your answer.

Yes, I tried it, but it didn't work... perhaps I need to use NCurses
(http://www.zend.com/pecl/tutorials/ncurses.php) ??

Best,

Sebastian

May 16 '06 #3
Rik
Tim Van Wassenhove wrote:
On 2006-05-15, Sebastian Araya <nu*****@gmail.com> wrote:
Hello,

I'm trying to write a rotational symbol in a CLI process, to report
activity to the user console, using printf( "%s\b", symbol ); but I
see the control character (\b) is been printed out instead of
backspacing.

Is there any work around ?


What about:
printf( "%s%c", symbol,8);

%c:
c - the argument is treated as an integer, and presented as the character
with that ASCII value

Then again, I know nothing about CLI.

Grtz,
--
Rik Wasmus
May 16 '06 #4
Hello,

I figured out with ANSI terminal control codes; here is a little
example:

<?

$sym = "|/-\\";

while( True )
for( $i = 0; $i!= 4; $i++ )
{
printf( "%s\x1b[D", substr( $sym, $i, 1 ) );
sleep(.25);
}

?>

I tested in a Gentoo 2006.0 using a SSH terminal under Windows
(PuTTy).

Best,

Sebastian

May 16 '06 #5
Hello Tim,

thanks again for your answer.

I think that, in PHP-CLI (console) environment, the screen is treated
as a common file, and every character output is send in a raw mode...
like if you use PHP under web development (where every output byte is
send through the net).

So, seeing Stefan Walk ProgressBar
(http://pear.php.net/package/Console_ProgressBar) I realized that using
ANSI terminal chars' control, you change the console behavior, so it
apparently deletes a char and writes a new one.

Best,

Sebastian

May 16 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
12
by: baumann | last post by:
hi all, printf("%c",b) doesn't work properly. #include <stdio.h> int a , b; char d, e; char * p; float f; int main(int argc, char* argv) {
36
by: Debaser | last post by:
I've recently read in one of my old C books that puts() is a better function call with regard to performance than printf() in the following situation: puts("Some random text"); vs. ...
15
by: bryanvick | last post by:
I just started learning C, and wrote this small program to play around with the printf function in stdio.h. At the console, I am able to type input at the first 2 getchar() calls, but when I call...
40
by: somenath | last post by:
Hi All, I have one question regarding the behavior of printf function. In page number of 154 in K&R2 in Table 7-1 it is stated that Characters Argument Type :...
3
by: Ioannis Vranos | last post by:
Is printf("%ls") for printing wchar_t strings defined in C90, or it was added in C95?
15
by: Ioannis Vranos | last post by:
I recall from previous discussions here, that we must cast a non-void pointer to void * before printing its value with printf("%p"). Is it true, and if yes why?
20
by: Sanchit | last post by:
I want to know how does printf (stdio library function) works? Does this depand on complier (I am using gcc on Linix) Does it uses some buffer in which it stores all what needed to be printed...
10
by: laikon | last post by:
Hello, everyone: this is about overflow in C and C++. int c = 400; printf("%c", c); it print ? on screen, and ascii of '?' is 63.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.