In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail what is meant by. /,.. /, / in the C++ path. The editor thinks it is quite practical, so I share it with you as a reference. I hope you can get something after reading this article.
". /": represents the current directory.
".. /" represents the directory above.
"/": represents the root directory.
Take a chestnut:
When reading a file, the path is written as follows
1. The file is in the current directory (take the image file as an example, the current project file is centered)
". / 1.jpg" or "1.jpg"
2. The files are in the upper directory
(1) under the upper directory
".. / 1.jpg"
(2) under an Image folder under the upper directory
".. / Image/1.jpg"
(3) under the upper directory
".. /.. / 1.jpg"
3. Files are located in the next level directory (Image1 folder)
". / Image1/1.jpg"
4. Root directory representation. Any page accesses Image.jpg images under Image.
"C:/Image/1.jpg"
Code example:
/ * Copyright (c) 2018 Young Fan.All Right Reserved. * Analysis of Filename: 8 path symbols * Author: Young Fan * Date: April 30, 2018.30 * OpenCV version: 3.4.1 * IDE: Visual Studio 2017 * Description: ". /", ".. /", "/" * / # includeusing namespace cv;int main () {Mat Image = imread (". / 1.jpg"); / / files are in the current directory imshow ("Test", Image); Mat Image1 = imread (".. / 1.jpg") / / files in the upper directory imshow ("Test1", Image1); Mat Image2 = imread (". / Image1/1.jpg"); / / files in the next level directory (Image1 folder) imshow ("Test2", Image2); Mat Image3 = imread (".. /.. / 1.jpg"); / / files in the upper directory imshow ("Test3", Image3); waitKey () Return 0;} supplement
The forward slash, also known as the left slash, is "/"; the backslash, also known as the right slash, is "\". The representation of file paths can be divided into absolute paths and relative paths:
Absolute path representation is relatively easy, such as
PDummyFile = fopen ("D:\ vctest\\ glTexture\\ texture\\ dummy.bmp", "rb"); all paths starting from the drive letter are given. Note that "\" double slash "\" is used here. The default directory accessed by vc project is the project directory, and the relative path has the following forms, such as: pDummyFile = fopen ("dummy.bmp", "rb"); bmp file is located in the vc project directory and belongs to the same directory as dsw file.
PDummyFile = fopen ("..\ texture\\ dummy.bmp", "rb"); indicates that the bmp file is in the sibling directory texture of the project directory, so the path is to exit the project directory and then enter the texture directory to access the bmp file. ".." Indicates going back to one level above the current directory (parent directory)
PDummyFile = fopen (".\\ texture\\ dummy.bmp", "rb"); indicates that the bmp file is in the subdirectory texture of the project directory, "." Indicates the current default directory, that is, the vc project directory, and then accesses the files by entering its subdirectory texture
Note that for relative paths, the "\" in the path representation also uses a double slash "\"
In C++,\\ is an escape character, which represents a\, just like\ nrepresents a carriage return.
So the path name in C++: d:\ matcom45\ doc\ users\ _ themes\ m.dat
It should be:
CStringfilename=_T ("D:\\ matcom45\\ doc\ users\\ _ themes\\ m.dat"); or CStringfilename=_T ("D:/matcom45/doc/users/_themes/m.dat")
This is the end of this article on "what does. /,.. /, / in the C++ path mean?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.