# what is the different between the \ and /

## Recommended Posts

derek7    100
when I use directory and file in programming I find both / and \ work.just use \\ instead of \. so what is the different else between the \ and / ?

##### Share on other sites
Wan    1366
There no real difference, "/" just doesn't need an escape character.
I think "\\" doesn't work for Unix type file systems, but I'm not sure.

##### Share on other sites
darookie    1441
The backslash ('\') is used as an escape character in C and C++ , so to represent the backslash itself you'll need to write '\\'. MS decided do use the backslash as primary path seperator, while all other (modern) OS' use the forward slash ('/').
So when programming for Windows only, the difference between both separators mainly is safety, since typos are less common while using forward slashes (remember the escape-character thing).
If your code is intended to compile on more than just the windows-platform, it is essential to use the forward slash as path separator, since most other OS' use it exclusively.

HTH,
Pat

##### Share on other sites
I think in the old days, you needed to use "\" for paths in Windows, and "/" for paths in Unix. But now Windows just lets you use either, for compatibility with unix-style paths.

##### Share on other sites
Guest Anonymous Poster
In the Olde Days?! Damn you young whipper snappers! :)

I believe that the forward slash is also a standard in web urls (e.g. when referring to directory paths in .html files)