Sign in to follow this  

the \ make sense only with c string function?

This topic is 4584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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
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

This topic is 4584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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