Tags: c file path absolute path relative path slash it classification: C and OPENCV
1
C file path Why use a double slash
Because \ is an escaped leading character in c/c++/c#, for example \ n represents a line break.
If the path has exactly the same escape character as the beginning, it can cause problems, so \ must be in the form of \ \ in the path.
2 The path to Windows indicates why the file hierarchy is "\" with backslashes, and UNIX systems are "/" with slashes?
Windows uses a backslash ("\") History from DOS, and another tradition of DOS is to use a slash ("/") to denote command-line arguments, such as:
CD%systemdrive%
DIR/S/b Shell32.dll
Since the DOS side slash is occupied, we have to find the closest one. That's it. In UNIX environments, we use a minus sign ("-") and a double minus sign ("--") to represent command-line arguments.
Using a slash to indicate a command-line argument is a compatibility reason. The problem originally originated with IBM. IBM contributed a large number of tools when it first joined DOS development by using slashes to handle command-line arguments. This tradition stems from dec/ibm, such as the VMS that used to handle command-line arguments with slashes, whose directory delimiter is the dollar symbol ("$"). By the way, this tradition has also been partially inherited into DOS and windows, and the Japanese version of Windows displays the backslash as "¥" on the screen, although it is actually a backslash.
Today's Windows kernel can actually support both slash and backslash when working with paths. Many times we see errors when using slashes because of application-level reasons. For example, Cmd.exe does not support using a slash to represent the path, and PowerShell.exe supports it, and for this reason PowerShell begins to use the minus sign as the starting character for the command line arguments.
Memory
Here's a clever notation: notice the first pen of the Word window, the first pen of the letter W, what is it? Yes, it's a backslash, so every time you think about Windows file path/or \, the first thing to think about is what the first pen of Windows is, and the answer comes naturally. As opposed to Windows, the natural use of Linux or UNIX file paths is/IS.
Some other knowledge
Relative path: The relative path refers to the path to the other file (or folder) that is caused by the path to which the file resides. The use of relative paths can bring us a lot of convenience. The following examples illustrate:
For example, the local hard disk has the following two files, they want to do hyperlinks to each other
G:\site\index.htm
G:\site\web\article\01.htm
index.htm to link to 01.htm this file, the correct link should be: Link text, which is the standard relative path.
In turn, 01.htm to link to index.htm this file, in the 01.htm file should be written in this sentence: Back to the first page. Here's the. /indicates an upward level.
Now that you know the concept of a relative path, it's simple and straightforward. If you still don't see it, have you ever learned dos before? It's "CD folder name" and "CD ..." Have you used the order? This is the same.
Note: The relative path of the folder symbol is a slash:/
Link text such a link, the first slash behind the href represents the root directory, usually we have to be particularly cautious in this way.
Absolute path
In WWW (wide area Network), links beginning with http are absolute paths.
Physical path?
A physical path refers to a local path of a computer, starting with a drive letter, such as C: \, D:\temp, and so on. In the ASP database connection, only the physical path can be connected, but the relative path cannot be connected, so the relative path needs to be transformed into a physical path using the Server.MapPath object.
\ is the path to the file, such as c:\windows\system\ ...
/is used to add parameters to Dos command, dir--display disk directory command
1. Function: Displays the contents of the disk directory.
2. Type: Internal command
3. Format: DIR [Drive letter] [path][/p][/w]
Instructions for use:/p use; When you want to view too many directories, you can not display the screen on a screen will be rolled up, not easy to see, plus/P parameters, the screen will be divided into 23 rows of file information, then pause, and prompt;
Any key to continue
The use of/w: plus/w only display the file name, as to the size of files and the date and time of establishment are omitted. After adding the parameters, each line can display five file names.
Source:
From for notes (Wiz)
Backslash forward slash and double slash problem with file path