Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这样的代码
wstring filename; wstring dirname; wstring disk;
然后我想以这种方式拆分文件的完整路径
_wsplitpath(&filepath[0],&disk[0],&dirname[0],NULL,NULL);
但我有一个例外。我做错了什么?
使用_wsplitpath_s它可以防止缓冲区溢出。还使用返回指向可变字符的指针并使用大小初始化它们的向量:
_wsplitpath_s
std::wstring filename; std::vector<wchar_t> disk(8); std::vector<wchar_t> dirname(1024); _wsplitpath_s( filename.c_str(), disk.data(), disk.size(), dirname.data(), dirname.size(), nullptr, 0, nullptr, 0 );