首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

c++ 带参数调用exe 参数中带空格怎么处理

2012-05-20 
c++ 带参数调用exe 参数中带空格怎么办本人新手 接触c++第一天 要写了程序调用外部exe看了论坛里的帖子 实

c++ 带参数调用exe 参数中带空格怎么办
本人新手 接触c++第一天 要写了程序调用外部exe
看了论坛里的帖子 实现了代码如下
#include <stdio.h> 

int main() 
{
char ss[100];

sprintf(ss, "%s -o %s %s", "C:\\FlashPaper\\FlashPaper2.2\\FlashPrinter.exe", "c:\\txt\\aaa.txt.swf", "c:\\txt\\aaa.txt");

system(ss);
}
调用FlashPrinter.exe 传参数输入路径的aaa.txt和输出路径的aaa.txt.swf
这个aaa.txt 是文件名 问题是如果这个文件名里面有空格就不能执行了
比如c:\\txt\\a a a.txt 程序就没法运行了 哪位高手能帮我改改

[解决办法]
用""括起来
[解决办法]
改成
#include <stdio.h>

int main()
{
char ss[100];

sprintf(ss, "%s -o %s %s", "C:\\FlashPaper\\FlashPaper2.2\\FlashPrinter.exe", "c:\\txt\\aaa.txt.swf", "\"c:\\txt\\a a a.txt\"");

system(ss);
}

热点排行