Windows的C系统调用命令空间 [英] windows C system call with spaces in command

查看:122
本文介绍了Windows的C系统调用命令空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能让系统调用在名字和参数空间。例如:

I cannot make system calls with spaces in the names and parameters. For example:

system("c:\\program files\\something\\example.exe c:\\my files\\example.txt");

我试图在每一个我知道如何逃脱的方法,并没有什么作品。我曾尝试:

I have tried escaping in every way I know how, and NOTHING works. I have tried:

system("\"c:\\program files\\something\\example.exe\" \"c:\\my files\\example.txt\"");

system("c:\\program^ files\\something\\example.exe c:\\my^ files\\example.txt");

无论是工作。我仍然得到C:\\程序不是计入初始确认内部或外部命令

Neither work. I still get 'c:\program' is not a recongnised internal or external command

这是真的快把我逼疯了......我需要调用,并通过有空格的参数。我不能使用短符号的原因,我不会进入。

This is really driving me mad... I need to call and pass parameters that have spaces in them. I cannot use the short notation for reasons I won't go into.

我试图与'引号,而不是行情,仍然无法正常工作。我试图把周围的整个事情的报价和报价周围的空间和不工作。

I have tried with ' quotes instead of " quotes, still doesn't work. I have tried putting quotes around the whole thing and quotes around the spaces and that doesn't work.

有谁知道如何正确地做呢?

Does anyone know how to do it properly?

推荐答案

编辑:确定,理解了它步进到系统()拨打:你需要一组额外的引号,由于周围的事实,它内部调用的 CMD / C yourinput

OK, figured it out by stepping into the system() call: you need an extra set of quotes around the whole thing due the fact that it internally calls cmd /c yourinput

所以这对我的作品:

system("\"\"c:\\program files\\internet explorer\\iexplore.exe\" \"www.stackoverflow.com\"\"");

乱了一下,是不是?

A bit of a mess, isn't it?

这篇关于Windows的C系统调用命令空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆