Thursday, March 13, 2014

Escape sequence and character set problem

Newsgroup: comp.lang.c++

Subject: Re: Escape sequence and character set problem

From: Victor Bazarov <v.bazarov@...>

Date: Thu, 13 Mar 2014 11:44:16 -0400



On 3/13/2014 11:39 AM, nvangogh wrote:

> What values does this literal represent? What type does it have?

> "Who goes with F\145rgus?\012"

>

> This is from C++ Primer exercise 2.7 (p41 of 5th ed)

>

> I cannot figure this out.

>

> F is a suffix for float that only makes sense to me if numeric value

> came before it. But it comes before an escape sequence. What does \145

> mean? Taken as a whole can you explain how this line is put together and

> how I can interpret it?



Inside a string literal, letter F has no special meaning. It's just a

letter. However, \145 is an escape sequence designating a special

character (most likely) with the value of decimal 145, which is actually

not possible in a basic character set limited to -127..127. So, most

likely it's substituted with char(255-145), some negative value, but

will yield the same thing however. Look up in the extended ASCII table

to see what your computer is likely to output. Or just write a small

program to output that literal. If we designate that character with the

asterisk (like in Scrabble) and the newline (the second escape sequence

is the line feed character) with the tilda, the literal becomes "Who

goes with F*rgus?~"



What it will do when you output it depends on the device, though.



V

--

I do not respond to top-posted replies, please don't ask







via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1iGNqBO

View all the progranning help forums at:

http://ift.tt/1dP9txN

No comments:

Post a Comment