Reputation: 99
Without backslash
unsigned char a=5;
With backslash
unsigned char a=\
5;
Given that both are working identically, then what is the actual use of backslash?
Upvotes: 1
Views: 1231
Reputation: 144780
The C Standard describes the second phase of program translation this way:
5.1.1.2 Translation phases
...
- Each instance of a backslash character (
\
) immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines. Only the last backslash on any physical source line shall be eligible for being part of such a splice. A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character before any such splicing takes place.
Hence there is no semantic difference between the 2 code fragments posted. These backslash new-line sequences can occur in the middle of a token too:
\
u\
ns\
ign\
ed c\
har a\
= 5;/\
/comment
Upvotes: 1
Reputation: 311428
A \
character at the end of a line means that the following line should be treated as the continuation of the previous line.
Since you're allowed to have whitespaces after the assignment (=
) operator, it's pointless in this case.
Upvotes: 4