NEWBIE:如何从字符串构造系统调用 [英] NEWBIE: how to construct a system call from strings

查看:68
本文介绍了NEWBIE:如何从字符串构造系统调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


如何构建多个字符串如何构造变量以传递给

system():

说日期命令


string str =" 14/10/08 19:06:09" ;;

strDD = str.substr(0,2 );

strMM = str.substr(3,2);

strYY = str.substr(6,2);

strhh = str.substr(9,2);

strmm = str.substr(12,2);

strss = str.substr(15,2);


STRT<<"日期-u"<< strMM<< strDD<< strhh<< strmm<< strYY<<"。"< ;< str ss<<

2>& 1> / dev / null;"<< endl;


system(strT);


当我编译它时抛出


rtchk.cpp:在函数`int main(int,char **)'':

rtchk.cpp:59:不匹配`string& << const char [9]''


所以我可能是语法错误,但我是新手。

如果有拼写错误,我可以没看到。

Hi all,

Having several strings how do I construct variable to pass to
system():
Lets say the date command

string str = "14/10/08 19:06:09";
strDD = str.substr(0,2);
strMM = str.substr(3,2);
strYY = str.substr(6,2);
strhh = str.substr(9,2);
strmm = str.substr(12,2);
strss = str.substr(15,2);

strT<<"date -u "<<strMM<<strDD<<strhh<<strmm<<strYY<<"."<<str ss<< "
2>&1 >/dev/null;"<<endl;

system(strT);

when I compile it throws

rtchk.cpp: In function `int main (int, char **)'':
rtchk.cpp:59: no match for `string & << const char[9]''

so i could be a syntax error, but I''m newbie.
if there is a typo, I can''t see it.

推荐答案

Atropo写道:
Atropo wrote:

大家好,
Hi all,



上次你问的答案有什么问题?


-

Ian Collins

What''s wrong with the answer I gave last time you asked?

--
Ian Collins


15月15日17:54,Ian Collins< ian-n ... @ hotmail.comwrote:
On 15 oct, 17:54, Ian Collins <ian-n...@hotmail.comwrote:

Atropo写道:
Atropo wrote:

大家好,
Hi all,



什么是我上次你问的答案错了吗?


-

Ian Collins


What''s wrong with the answer I gave last time you asked?

--
Ian Collins



对不起伊恩。我虽然这些帖子在几个小时之后被删除了刷新

这个帖子从未显示的网页..

Sorry Ian. I though those post were deleted after hours refreshing
the webpage this post never shows..


Atropo写道:
Atropo wrote:

15月15日17:54,Ian Collins< ian-n ... @ hotmail.comwrote:
On 15 oct, 17:54, Ian Collins <ian-n...@hotmail.comwrote:

> Atropo写道:
>Atropo wrote:

>>大家好,
>>Hi all,


我上次给出的答案有什么问题你问过吗?

What''s wrong with the answer I gave last time you asked?



*请*不要引用签名。

*Please* don''t quote signatures.


>

对不起伊恩。我虽然这些帖子在数小时后删除了刷新

这个帖子从未显示的网页..
>
Sorry Ian. I though those post were deleted after hours refreshing
the webpage this post never shows..



Usenet不是IM,你有给消息传播时间。那个可怕的谷歌界面似乎让事情变得更糟。


-

Ian Collins

Usenet isn''t IM, you have to give messages time to propagate. That
dreadful google interface appears to make things worse.

--
Ian Collins


这篇关于NEWBIE:如何从字符串构造系统调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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