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