473,416 Members | 1,564 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,416 software developers and data experts.

why is the backslash-space combo a escape sequence 040

The printf function returns "warning: unknown escape sequence: \040"
for a backslash-space combination. If the ascii decimal number for
space is 32 and the backslash is 92, why this particular number 040?
Is it a decimal number from the ASCII code chart? (compiling using gcc
on SunOS 5.8, Sparc, Ultra-80)
Just curious. Thanks.

Sep 23 '07 #1
5 15624
In article <11**********************@r29g2000hsg.googlegroups .com>,
vlsidesign <fo*****@gmail.comwrote:
>The printf function returns "warning: unknown escape sequence: \040"
for a backslash-space combination. If the ascii decimal number for
space is 32 and the backslash is 92, why this particular number 040?
Is it a decimal number from the ASCII code chart?
It is an octal number from the ASCII code chart. 4*8^1 + 0*8^0 = 32 (decimal)
--
Programming is what happens while you're busy making other plans.
Sep 23 '07 #2
vlsidesign <fo*****@gmail.comwrites:
The printf function returns "warning: unknown escape sequence: \040"
for a backslash-space combination. If the ascii decimal number for
space is 32 and the backslash is 92, why this particular number 040?
Is it a decimal number from the ASCII code chart? (compiling using gcc
on SunOS 5.8, Sparc, Ultra-80)
I doubt that the printf function itself is returning this message; the
only escape sequences printf knows about are the ones introduced by
the '%' character. Probably you're using "\040" in a string literal,
and your compiler is complaining about it; the fact that you're using
that string literal in a printf call is irrelevant. Try using the
string literal in another context, and you should get the same message:

char *s = "your literal";

In a string or character literal, the sequence \040 denotes the octal
value of the character (your C textbook should explain this). 040
octal is 32 decimal, which happens to be the ASCII code for the space
character (though C doesn't require ASCII).

It would have been very helpful if you had posted the actual
copy-and-pasted code that caused the problem.

Here's a small C translation unit:

char *backslash_space = "\ ";
char *backslash_bang = "\!";

and gcc's output:

c.c:1:25: warning: unknown escape sequence: '\040'
c.c:2:25: warning: unknown escape sequence '\!'

Presumably gcc shows the space character as 040 to avoid the visual
ambiguity of printing the actual space character.

The C standard doesn't specify the form of diagnostic messages;
compilers other than gcc will produce different messages. For
example, here's the output of another compiler:

"c.c", line 1: warning: dubious escape: \
"c.c", line 2: warning: dubious escape: \!

and another:

"c.c", line 1.25: 1506-235 (W) Incorrect escape sequence \ . \ ignored.
"c.c", line 2.25: 1506-235 (W) Incorrect escape sequence \!. \ ignored.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 23 '07 #3
On Sun, 23 Sep 2007 07:05:37 +0000, vlsidesign wrote:
The printf function returns "warning: unknown escape sequence: \040"
for a backslash-space combination. If the ascii decimal number for
space is 32 and the backslash is 92, why this particular number 040?
Is it a decimal number from the ASCII code chart?
040 is octal for 32.
Backslashes in string literals are always taken as escape
sequences. If you want to use one, try "\\".

--
Army1987 (Replace "NOSPAM" with "email")
A hamburger is better than nothing.
Nothing is better than eternal happiness.
Therefore, a hamburger is better than eternal happiness.

Sep 23 '07 #4
vlsidesign wrote:
>
The printf function returns "warning: unknown escape sequence:
\040" for a backslash-space combination. If the ascii decimal
number for space is 32 and the backslash is 92, why this
particular number 040? Is it a decimal number from the ASCII code
chart? (compiling using gcc on SunOS 5.8, Sparc, Ultra-80)
It's the octal code for a space, as indicated by the leading 0.
The 'escape space' combination is only valid at the termination of
a C source line, and is effectively absorbed.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Sep 23 '07 #5
CBFalconer <cb********@yahoo.comwrites:
vlsidesign wrote:
>The printf function returns "warning: unknown escape sequence:
\040" for a backslash-space combination. If the ascii decimal
number for space is 32 and the backslash is 92, why this
particular number 040? Is it a decimal number from the ASCII code
chart? (compiling using gcc on SunOS 5.8, Sparc, Ultra-80)

It's the octal code for a space, as indicated by the leading 0.
The 'escape space' combination is only valid at the termination of
a C source line, and is effectively absorbed.
No, a backslash followed by a space is not legal at the end of a line.
A backslash can be used to join two logical lines but the backslash
must *immediately* precede the new-line character. See C99 5.1.1.2p2.

Some compilers may allow spaces after a backslash as an extension.
It's a reasonable one, since trailing whitespace is typically
invisible. Variations in text file formats may also affect this.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 23 '07 #6

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

Similar topics

5
by: Ladvánszky Károly | last post by:
What is the correct way to match/search a backslash with regular expressions? print re.match('\\m', '\\m').group(0) raises an error while print re.search('\\m', '\\m').group(0) yields 'm' ...
1
by: Craig Stadler | last post by:
mySQL 4.0.20a WIN32 Need help with backslash syntax/like queries.. Query1: select * from dbtable1 where Filespec like 'http://www.10291.com/%' returns :...
3
by: Sathyaish | last post by:
In trying to replace character literals for their char constant, I am having difficulty printing the char constant for backslash. It instead prints the char literal. How do I resovle this? ...
6
by: John Salerno | last post by:
I have this: subdomain = raw_input('Enter subdomain name: ') path = r'C:\Documents and Settings\John Salerno\My Documents\My Webs\1and1\johnjsalerno.com\' + subdomain Obviously the single...
2
by: John Dann | last post by:
I guess there must be some convention or Windows specification for whether the backslash immediately preceding the file name in a full path string to a file is formally part of the path string or...
5
by: shalini jain | last post by:
Hi, I want to know how to use split function to split the string based on backslash(\). Actually backslash is appearing at the end of the string. and i want to remove it. so if anyone could guide...
3
by: Stef Mientki | last post by:
It looks like sometimes a single backslash is replaced by a double backslash, but sometimes it's not ??? See the error message below, the first backslash is somewhere (not explicitly in my code)...
2
by: Tobiah | last post by:
>>"'" "'" "'" "\\'" "\\'" This is quite different than any other language that I am used to. Normally, a double backslash takes away the special meaning of the last backslash, and so you...
4
by: Razzbar | last post by:
I'm working on a bookmarklet that grabs information from a page and submits it to a server. Yet another social bookmarking application. I'm having trouble with page titles that include an...
4
nithinpes
by: nithinpes | last post by:
I will boil down my exact requirement to this: I should print out lines that do not contain semi-colon, backslash and closing parentheses. The following one -liner works fine. perl -ne "unless(//)...
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...
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
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.