C++ 需要c&x2B的协助+;系统()函数

C++ 需要c&x2B的协助+;系统()函数,c++,system,C++,System,好的,我写了一个程序,它扫描所有目录和子目录以查找sepcific文件扩展名(我传递了一个字符串作为我想要的扩展名类型),然后它返回一个向量loade,其中包含具有特定文件扩展名的所有文件名。然后我有另一个类,它有一个函数,可以打印出向量中的所有文件,然后迭代向量,在用户选择的向量中运行程序。这是我的问题。正在从vvector获取要运行的文件。我正在Windows7上使用visual Studio 使用boostfilesv3。这是我目前的职能: #define BOOST_FILESYSTEM

好的,我写了一个程序,它扫描所有目录和子目录以查找sepcific文件扩展名(我传递了一个字符串作为我想要的扩展名类型),然后它返回一个向量loade,其中包含具有特定文件扩展名的所有文件名。然后我有另一个类,它有一个函数,可以打印出向量中的所有文件,然后迭代向量,在用户选择的向量中运行程序。这是我的问题。正在从vvector获取要运行的文件。我正在Windows7上使用visual Studio 使用boostfilesv3。这是我目前的职能:

#define BOOST_FILESYSTEM_NO_DEPRECATED

#ifndef NotePad__h
#define NotePad__h

#include boost/filesystem.hpp
#include iostream
#include io.h
#include stdlib.h
#include stdio.h
#include cstdlib
#include Windows.h
#include atlstr.h
#include string
#include cstring
;
namespace fs = boost::filesystem;

class NpLaunch 
{
public:
    void Launch (const std::vector<fs::path>& v)
    {
        int count=0;
        std::cout << "launched in notePad.h" << std::endl;
        for(auto i = v.begin(); i!= v.end(); ++i)
        {
            //string s;
            //string val = (string) itr;
            std::cout << count << ". " << *i << std::endl;
            ++count;
            std::string s = i->c_str();
            //std::system(i->c_str());
        }
    }

};

#endif
\define BOOST\u FILESYSTEM\u NO\u已弃用
#ifndef记事本
#定义记事本
#包括boost/filesystem.hpp
#包括iostream
#包括io.h
#包括stdlib.h
#包括stdio.h
#包括cstdlib
#包括Windows.h
#包括atlstr.h
#包含字符串
#包括cstring
;
名称空间fs=boost::filesystem;
第n类发射
{
公众:
无效启动(const std::vector&v)
{
整数计数=0;

std::cout在Windows上,
path::value_type
是一个
wchar_t
,因此
path::string_type
等同于
std::wstring
,而
path::c_str()
方法返回一个
wchar\u t*
。您不能将
wchar\u t*
分配给
std::string
,这就是编译器错误试图告诉您的

要将
path
对象分配给
std::string
,必须执行从
wchar\u t
char
的字符转换。
path::string()
方法为您执行此操作,例如:

std::string s = i->string(); 
否则,请改用
std::wstring
,您可以使用
path::native()
path::wstring()
方法将其分配给它,例如:

std::wstring s = i->native(); 

std::wstring s = i->wstring(); 

想知道是否应该做一个静态的演员,如果这将工作。不寻找答案,但提示/提示只是一个猜测,尝试wstring而不是字符串。谢谢你,但我把它弄出来大约2分钟后,我发布了这个哈哈,但无论如何谢谢