views:

240

answers:

4

I'm totally confused which one to use and when, first thing I do when something goes wrong in code with a slash is replace the one with other so my test cases double with one for / and one for \ .Help me to get the logic behind slashes.

+4  A: 

/ is generally used to denote division as in 10/2 meaning 10 divided by 2. \ is generally used as an escape character as in \t or \n representing a tab and a newline character respectively.

abhin4v
+7  A: 

From the wikipedia article about the backslash:

Bob Bemer introduced the \ character into ASCII, on September 18, 1961, as the result of character frequency studies. In particular the \ was introduced so that the ALGOL boolean operators "∧" (AND) and "∨" (OR) could be composed in ASCII as "/\" and "\/" respectively.[4] Both these operators were included in early versions of the C programming language supplied with Unix V6 , Unix V7 and more currently BSD 2.11.

Wim Coenen
As I said in the comment, ASCII drawing it is.
abhin4v
+1  A: 

There's nothing like a "forward slash". There's a "slash" / and a "backslash" \.

There's a long and IMHO ilarious discussion about that on the xkcd forum

nico
A: 

One More Thing....

The Forward Slash / Used in Linux/Unix Like OS To Nevigate the Filesystem...

Like .... /root/home/Viz

and The BackSlash \is Used In Windows ...

Like ..... F:\Games\CounterStrike

Vizay Soni