vlsidesign said:
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.