hello world

S

surena abari

Hi,

When writing the hello world program I insert \b in various locations
in the sentence.It works(making backspace) except when inserting
it after world\b.It dose not work.
Printf("hello, world\b")
Why?

Surena.
 
B

Ben Pfaff

When writing the hello world program I insert \b in various locations
in the sentence.It works(making backspace) except when inserting
it after world\b.It dose not work.
Printf("hello, world\b")

What actually gets displayed? This should display "hello,
world". Perhaps you are unaware of what \b is supposed to mean
for a display device:

\b (backspace) Moves the active position to the previous
position on the current line. If the active position is
at the initial position of a line, the behavior of the
display device is unspecified.
 
B

Barry Schwarz

Hi,

When writing the hello world program I insert \b in various locations
in the sentence.It works(making backspace) except when inserting
it after world\b.It dose not work.
Printf("hello, world\b")
Why?
What makes you think it doesn't work? What do expect to be different
with the \b in the string than without the \b? Remember, the
backspace need not be destructive.

If you are using a windows system, look very carefully at the
placement of the cursor. It should be under the d. Then remove the
\b and try again. It should be to the right of the d.


<<Remove the del for email>>
 
S

surena abari

Barry Schwarz said:
If you are using a windows system, look very carefully at the
placement of the cursor. It should be under the d. Then remove the
\b and try again. It should be to the right of the d.

Thanks for explaining the meaning of \b for me.
I have similar problems with other escape characters.
But I think this group it is not the proper place to
ask this questions as they are not related to C.
So would you please give me a reference(book or website)
that gives me the exact meaning of these characters?

Surena.
 
B

Ben Pfaff

Thanks for explaining the meaning of \b for me.
I have similar problems with other escape characters.
But I think this group it is not the proper place to
ask this questions as they are not related to C.
So would you please give me a reference(book or website)
that gives me the exact meaning of these characters?

Here is what the C standard says about them:

2 Alphabetic escape sequences representing nongraphic characters
in the execution character set are intended to produce
actions on display devices as follows:

\a (alert) Produces an audible or visible alert without
changing the active position.

\b (backspace) Moves the active position to the previous
position on the current line. If the active position is
at the initial position of a line, the behavior of the
display device is unspecified.

\f (form feed) Moves the active position to the initial
position at the start of the next logical page.

\n (new line) Moves the active position to the initial
position of the next line.

\r (carriage return) Moves the active position to the
initial position of the current line.

\t (horizontal tab) Moves the active position to the next
horizontal tabulation position on the current line. If
the active position is at or past the last defined
horizontal tabulation position, the behavior of the
display device is unspecified.

\v (vertical tab) Moves the active position to the initial
position of the next vertical tabulation position. If
the active position is at or past the last defined
vertical tabulation position, the behavior of the
display device is unspecified.
 
D

Dan Pop

In said:
When writing the hello world program I insert \b in various locations
in the sentence.It works(making backspace) except when inserting
it after world\b.It dose not work.
Printf("hello, world\b")
Why?

You're confusing the effect of pressing the Backspace key on your console
with the effect of the ASCII BS character itself.

When you press Backspace, on a console using or emulating a glass TTY
device, the computer typically echoes back the BS, space, BS sequence,
effectively erasing the last character typed before BS. That wouldn't
be particularly effective on a real TTY device, so you'd get a different
reaction from the computer, if you made it aware that your console is
some form of serial printer.

Also beware of "orphan" CR characters, i.e. characters that were, once,
part of a CR+LF pair, but the programmer has inadvertently removed the
LF only (usually because he was unaware of the presence of the CR).
If you have such a character in the middle of a line, the output may be
different from your expectations and the reason quite elusive.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Hello Everyone! 2
Hello World 2
Hello there.. 3
How do I load my "Hello World" ASP in a browser? 1
Hello everyone ! 4
Hello there 3
Hello Everybody 0
Hello to community. 3

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top