Jump to content
  • Advertisement
Sign in to follow this  

what is the different between the \ and /

This topic is 4742 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

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


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
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 this post


Link to post
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 this post


Link to post
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)


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!