C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c – 无法将FindFileData.cFileName转换为字符串大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在取得很大进展,但我有两个问题让我放慢了几天.最大的是我想将FindFileData.cFilename保存为字符串,但我不能!有帮助吗?

解决方法

我从这里复制了这个: How to convert wstring into string?
它将wString直接转换为字符串(包括FindFileData.cFileName).有什么更好的建议或任何有用的评论
#include <clocale>
#include <locale>
#include <String>
#include <vector>

inline std::string narrow(std::wString const& text)
{
    std::locale const loc("");
    wchar_t const* from = text.c_str();
    std::size_t const len = text.size();
    std::vector<char> buffer(len + 1);
    std::use_faCET<std::ctype<wchar_t> >(loC).narrow(from,from + len,'_',&buffer[0]);
    return std::string(&buffer[0],&buffer[len]);
}

大佬总结

以上是大佬教程为你收集整理的c – 无法将FindFileData.cFileName转换为字符串全部内容,希望文章能够帮你解决c – 无法将FindFileData.cFileName转换为字符串所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。