C++;当路径有空间时,system()无法打开.txt文件
我在e:/a/b中有txt文件 In system()函数无法接受空格 那怎么办呢 我的C++代码是< /p>C++;当路径有空间时,system()无法打开.txt文件,system,System,我在e:/a/b中有txt文件 In system()函数无法接受空格 那怎么办呢 我的C++代码是< /p> #include <iostream> #include <conio.h> using namespace std; int main() { system("start e:/a b/test.txt"); } #包括 #包括 使用名称空间std; int main() { 系统(“启动e:/ab/test.txt”); } 您需要的是模拟您将
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
system("start e:/a b/test.txt");
}
#包括
#包括
使用名称空间std;
int main()
{
系统(“启动e:/ab/test.txt”);
}
您需要的是模拟您将在命令行上执行的操作。例如:
system("start \"e:/a b/test.txt\"");
另一方面,通常对批处理文件使用.bat扩展名。不确定扩展名的start有多挑剔,但它有助于理解。我通常将start大写字母设置为start,并将其用作
系统(“start www.gmail.com”)代码>或者您可以使用
system(“START*URL或EXE-FILE*”代码>打开它的另一种方式是:
CString str = "http://www.wikipedia.org/";
CString action = "open";
ShellExecute(NULL, action, str, NULL, NULL, SW_SHOW);
getchar();
都德它不打开txt文件它打开cmd都德它不打开txt文件它打开cmd