Question about the forward and backward slash ("/\") and double slash ("\") of the file path

Source: Internet
Author: User

1. Why should I use a double slash in the C file path?

Because "\" is a leading Escape Character in C/C ++/C #, for example, "\ n" indicates a line break.
If the path begins with an escape character, it will cause a problem. Therefore, the \ In the path must be in the \ format.

2. Why is the Backslash "\" used to indicate the file level in the Windows path, and the slash "/" used in UNIX systems 「/」?
In Windows, the backslash ("\") is used from Dos, while in DOS, another tradition is to use a slash ("/") to represent command line parameters. For example:

 
Cd % systemdrive %Dir/S/B shell32.dll

 

Since the DOS slashes are occupied, we have to find the closest one. That's it. In UNIX, we use minus signs ("-") and double minus signs ("--") to represent the command line parameters.
Using a slash to indicate that the command line parameters are compatible. This problem was originally originated from IBM. IBM contributed a large number of tools when it first joined DOS development, all of which use slashes to process command line parameters. This tradition originated from Dec/IBM. For example, VMS used a slash to process command line parameters. Its Directory separator is the dollar sign ("$ "). By the way, this tradition has been partially inherited into the DOS and Windows systems, and the Japanese version of Windows displays the backslash as "¥" on the screen ", it is actually a backslash.

Currently, the Windows kernel supports both slash and backslash when processing the path. Many times we see an error when using a slash becauseApplication Layer. For example, cmd.exe does not support the use of diagonal bars, while powershell.exe does. For this reason, powershell starts to use the minus sign as the start character of the command line parameter.

Here is a coincidence: Pay attention to the first word of window, that is, the first letter of W. What is it? Yes, it's a backslash.When using/or \ in the Windows file path, you must first think about what is Windows's firstThe answer will naturally come out.As the opposite of windows, Linux or Unix File paths are naturally.

Question about the forward and backward slash ("/\") and double slash ("\") of the file path

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.