Sign in to follow this  
derek7

the \ make sense only with c string function?

Recommended Posts

doynax    850
The backslash used as a prefix for escape character can be used both in string constants and as single character literals. Besides that they are also used as line continuations for macros (in C anyway).

Share this post


Link to post
Share on other sites
smart_idiot    1298
In a string \ is a normal character like all the others, but it gets treated specially when compiling as it is used to escape characters. So to actually put a \ character in a string, you would need to write '\\'.

(a common bug for windows programmers to write something like "C:\folder\newstuff\test", which is wrong. \f gets translated to a form feed character, \n becomes a newline, and \t becomes a tab character.)

Share this post


Link to post
Share on other sites
SirLuthor    364
Quote:
Original post by doynax
The backslash used as a prefix for escape character can be used both in string constants and as single character literals. Besides that they are also used as line continuations for macros (in C anyway).

And in C++ as well. And not just for macros, they are also useful when your lines of code are getting too long to be seen without sideways scrolling [sick]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this