分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow
也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!
工作后比较忙,没大块的时间来酝酿博客的写作,所以随时记点笔记,一来方便自己查阅,二来也督促自己学习和总结。如果能对大家有所帮助,就更加开心了。
判断路径的包含关系是Windows系统复制移动文件夹的前置条件,比如将C:\test复制到C:\test\test1下就是不可行的。前一篇《【MoreWindows工作笔记6】PathCommonPrefix 路径的公共前缀》介绍了使用函数提取路径的公共前缀,并使用公共前缀来判断路径的包含关系,本篇将介绍一个更简单的API函数来判断路径的包含关系——PathIsPrefix。下面请看完整的代码示范和运行结果:
// 【MoreWindows工作笔记7】PathIsPrefix 判断路径的包含关系// http://blog.csdn.net/morewindows/article/details/17078627#include <windows.h>#include <Shlwapi.h>#include <string>#include <iostream>using namespace std;#pragma comment(lib, "shlwapi.lib")int main(){ printf(" 【MoreWindows工作笔记7】PathIsPrefix 判断路径的包含关系\n"); printf(" - http://blog.csdn.net/morewindows/article/details/17078627 -\n"); printf(" -- By MoreWindows( http://blog.csdn.net/MoreWindows ) --\n\n"); string src_path = "C:\\test1\\test"; //"\\home\\test1\\test"; string des_path = "C:\\test1\\test2"; //"\\home\\test1\\test2"; if (PathIsPrefix(src_path.c_str(), des_path.c_str())) cout<<"目标路径: "<<des_path<<" 包含\n"<<"源路径: "<<src_path<<endl; else cout<<"目标路径: "<<des_path<<" 不包含\n"<<"源路径: "<<src_path<<endl; cout<<"-----------------------------------"<<endl; return 0;}
运行结果如图所示:
地址:http://blog.csdn.net/morewindows/article/details/17078627 转载请标明出处,谢谢。
欢迎关注微博:http://weibo.com/MoreWindows