Forward Slash, also known as the left slash, the symbol is "/", the backslash is also called the right slash, the symbol is "\".

Source: Internet
Author: User
Forward Slash, also known as the left slash, the symbol is "/", the backslash is also called the right slash, the symbol is "\".
  
In Unix/linux, the path is delimited by a forward slash "/", such as "/home/hutaow", whereas in Windows, the path is delimited with a backslash "\", such as "C:\Windows\System".
  
Sometimes we will see this path to write, "C:\\Windows\\System", that is, with two backslashes to separate the path, which is often seen in Web applications or programming, in fact, the above path can be replaced with "C:/windows/system", no error. But if you write "C:\Windows\System," there may be a variety of strange mistakes.
The reasons for the above problems should be analyzed from the aspect of string parsing.
Anyone who has learned to program should know that in C, when the output string is if you want to output a newline, add ' \ n ' This flag, like, output a tab, plus ' \ t ', that is, the backslash ("\") This symbol will be followed by the character of the combination to escape to other characters. According to this principle, if you want to output double quotes (' "), you need to enter ' \ ', so that the string containing the double quotes is written in memory correctly. So if you want to enter a backslash. It's simple, just knock ' \ ' on it.
  
See here maybe some people have seen the point, if "C:\Windows\System" this path string to the C compiler to compile, the actual write memory string does not contain the backslash "\", even the letter immediately after the backslash is also escaped with the other characters, It's bound to go wrong if you call again.
String parsing is not limited to the C compiler, Java compilers, some configuration file parsing, Web servers, and so on, you will encounter the problem of parsing the string, because traditional Windows uses a single slash-delimited form of the path, Causes unnecessary errors when parsing the file path, so there is a way to separate the paths with a double backslash "\". Regardless of whether the parsing engine resolves the backslash to an escape character, the end result in memory is "\" and the results are not problematic.
  
It can also be seen that Windows or DOS in the early stages of design considerations, in order to distinguish with UNIX features, the forward slash in Unix "/" separated path to the backslash "\". One problem with this change is that in the early DOS command line, a normal file name cannot contain spaces, and if a space is included, the command resolution cannot distinguish it from the parameter area if the file name is entered. For example, to enter the directory of "Hutaow Yuan" (which ignores the 8.3 naming rules first), enter "CD Hutaow Yuan" directly, and the command line resolves it to go into the "Hutaow" directory, and the "Yuan" behind it is clearly not expected.
In Unix, the file name, if it contains spaces, can be escaped directly with the backslash "\" in front of the space, which distinguishes it from the command parameters (usually separated by spaces). Or the example above, in Unix, as long as you type "CD hutaow\ Yuan" (in front of the yuan before the space plus "\"), the command line to correctly identify the "Hutaow yuan" and enter this directory.
Of course, the next version of Windows is now using other methods, such as the file name enclosed in double quotes, to solve the space problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.