IP地址,文件解析 - 帮助 [英] IP Address, File Parsing - Help

查看:73
本文介绍了IP地址,文件解析 - 帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用VC ++ 6.0编写一个程序来读取一个txt文件,其中
看起来像这样:


网络目标网络掩码网关接口

指标

0.0.0.0 0.0.0.0 10.155.12.1 10.155.12.188

1

10.155.12.0 255.255.255.0 10.155.12.188 10.155.12.188

1

10.155.12.188 255.255.255.255 127.0.0.1 127.0.0.1

1

10.255.255.255 255.255.255.255 10.155.12.188 10.155.12.188

1

127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1

1

224.0.0.0 224.0.0.0 10.155.12.188 10.155.12.188

1


然后让它拉出两个不同的变量(IP地址)来自文件

并将它们作为打印字符放在另一个命令行中,以便与

system()命令一起使用。结束命令看起来像

这个......


系统(路由添加xxxx掩码255.0.0.0 yyyy metric 1)


xxxx将是从文件中获得的一个IP地址,并且

yyyy将是第二个。文件中的行是常量,

但是xxxx和yyyy会有所不同...


有什么建议吗?


一如既往,非常感谢任何帮助。


谢谢,

Rob


[见 http://www.gotw.ca/resources/clcm.htm有关信息]

[comp.lang.c ++。moderated。第一次海报:做到这一点! ]

解决方案



" Rob" < RO ****** @ yahoo.com>在消息中写道

news:34 ************************* @ posting.google.co m ... < blockquote class =post_quotes>我正在尝试用VC ++ 6.0编写一个程序来读取一个如下所示的txt文件:

网络目标网络掩码网关接口
度量标准
0.0.0.0 0.0.0.0 10.155.12.1 10.155.12.188
1
10.155.12.0 255.255.255.0 10.155.12.188 10.155.12.188
1
10.155.12.188 255.255。 255.255 127.0.0.1 127.0.0.1
1
10.255.255.255 255.255.255.255 10.155.12.188 10.155.12.188
1 / / 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1
1
224.0.0.0 224.0.0.0 10.155.12.188 10.155.12.188
1
然后从文件中提取两个不同的变量(IP地址)
并将它们作为打印的char'放在另一个命令行中,用于
system()命令。结束命令看起来像
这个......

系统(路由添加xxxx掩码255.0.0.0 yyyy metric 1)

xxxx会是从文件中获得的一个IP地址,并且yyyy将是第二个。文件中的行是不变的,
但是xxxx和yyyy会有所不同......

有什么建议吗?




是。发布你的代码,我们会提供帮助。

请更清楚地表达你的目标。


-Mike





打开一个小溪


读取它们


string Destination,Netmask,Gateway,Interface;


File>>目的地>>网络掩码>>网关>>界面


stringstream命令;


命令<< 路线添加 <<目的地<< "掩码255.0.0.0 << Gateway<<

"公制1;


系统(Command.str()。c_str());


关注Ron AF Greve。

" Rob" < RO ****** @ yahoo.com>在消息中写道

news:34 ************************* @ posting.google.co m ... < blockquote class =post_quotes>我正在尝试用VC ++ 6.0编写一个程序来读取一个如下所示的txt文件:

网络目标网络掩码网关接口
度量标准
0.0.0.0 0.0.0.0 10.155.12.1 10.155.12.188
1
10.155.12.0 255.255.255.0 10.155.12.188 10.155.12.188
1
10.155.12.188 255.255。 255.255 127.0.0.1 127.0.0.1
1
10.255.255.255 255.255.255.255 10.155.12.188 10.155.12.188
1 / / 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1
1
224.0.0.0 224.0.0.0 10.155.12.188 10.155.12.188
1
然后从文件中提取两个不同的变量(IP地址)
并将它们作为打印的char'放在另一个命令行中,用于
system()命令。结束命令看起来像
这个......

系统(路由添加xxxx掩码255.0.0.0 yyyy metric 1)

xxxx会是从文件中获得的一个IP地址,并且yyyy将是第二个。文件中的行是不变的,
但是xxxx和yyyy会有所不同......

有什么建议吗?




[见 http://www.gotw.ca/resources/clcm.htm 有关的信息]

[comp.lang.c ++。moderated。第一次海报:做到这一点! ]




" Rob" < RO ****** @ yahoo.com>在消息中写道

news:34 ************************* @ posting.google.co m ... < blockquote class =post_quotes>我正在尝试用VC ++ 6.0编写一个程序来读取一个如下所示的txt文件:

网络目标网络掩码网关接口
度量标准
0.0.0.0 0.0.0.0 10.155.12.1 10.155.12.188
1
10.155.12.0 255.255.255.0 10.155.12.188 10.155.12.188
1
10.155.12.188 255.255。 255.255 127.0.0.1 127.0.0.1
1
10.255.255.255 255.255.255.255 10.155.12.188 10.155.12.188
1 / / 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1
1
224.0.0.0 224.0.0.0 10.155.12.188 10.155.12.188
1
然后从文件中提取两个不同的变量(IP地址)
并将它们作为打印的char'放在另一个命令行中,用于
system()命令。结束命令看起来像
这个......

系统(路由添加xxxx掩码255.0.0.0 yyyy metric 1)

xxxx会是从文件中获得的一个IP地址,并且yyyy将是第二个。文件中的行是不变的,
但是xxxx和yyyy会有所不同......

有什么建议吗?

一如既往,非常感谢任何帮助。




你可以创建一个类似于&存储您想要阅读的实际数据记录

。这个类当然应该具有访问函数以及作为插入器和提取器操作符的
。使用流迭代器&一个集合

从文件中读取记录并将它们存储在容器中。那么你

只需迭代容器访问相应的信息

你需要组装字符串。


如果你需要更多帮助然后发布你已经拥有的一些代码。


HTH

克里斯



[见 http://www.gotw.ca/resources/clcm.htm 有关的信息]

[comp.lang.c ++。moderated。第一次海报:做到这一点! ]


I am trying to write a program with VC++ 6.0 to read a txt file which
looks like this:

Network Destination Netmask Gateway Interface
Metric
0.0.0.0 0.0.0.0 10.155.12.1 10.155.12.188
1
10.155.12.0 255.255.255.0 10.155.12.188 10.155.12.188
1
10.155.12.188 255.255.255.255 127.0.0.1 127.0.0.1
1
10.255.255.255 255.255.255.255 10.155.12.188 10.155.12.188
1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1
1
224.0.0.0 224.0.0.0 10.155.12.188 10.155.12.188
1

Then have it pull two different variables (IP Addresses) from the file
and put them as printed char''s in another command line to be used with
the system() command. The end command would look something like
this...

system("route add x.x.x.x mask 255.0.0.0 y.y.y.y metric 1")

The x.x.x.x would be one IP Address obtained from the file, and
y.y.y.y would be the second. The Line in the file would be constant,
but the x.x.x.x and y.y.y.y would vary...

Any suggestions?

As always, any help is greatly appreciated.

Thanks,
Rob

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

解决方案


"Rob" <ro******@yahoo.com> wrote in message
news:34*************************@posting.google.co m...

I am trying to write a program with VC++ 6.0 to read a txt file which
looks like this:

Network Destination Netmask Gateway Interface
Metric
0.0.0.0 0.0.0.0 10.155.12.1 10.155.12.188
1
10.155.12.0 255.255.255.0 10.155.12.188 10.155.12.188
1
10.155.12.188 255.255.255.255 127.0.0.1 127.0.0.1
1
10.255.255.255 255.255.255.255 10.155.12.188 10.155.12.188
1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1
1
224.0.0.0 224.0.0.0 10.155.12.188 10.155.12.188
1

Then have it pull two different variables (IP Addresses) from the file
and put them as printed char''s in another command line to be used with
the system() command. The end command would look something like
this...

system("route add x.x.x.x mask 255.0.0.0 y.y.y.y metric 1")

The x.x.x.x would be one IP Address obtained from the file, and
y.y.y.y would be the second. The Line in the file would be constant,
but the x.x.x.x and y.y.y.y would vary...

Any suggestions?



Yes. Post your code, and we''ll offer assistance.
And express your goal a bit more clearly, please.

-Mike


Hi,

Open a stream

read them

string Destination, Netmask, Gateway, Interface;

File >> Destination >> Netmask >> Gateway >> Interface

stringstream Command;

Command << "route add " << Destination << " mask 255.0.0.0 " << Gateway <<
" metric 1";

system( Command.str().c_str() );

Regards Ron AF Greve.
"Rob" <ro******@yahoo.com> wrote in message
news:34*************************@posting.google.co m...

I am trying to write a program with VC++ 6.0 to read a txt file which
looks like this:

Network Destination Netmask Gateway Interface
Metric
0.0.0.0 0.0.0.0 10.155.12.1 10.155.12.188
1
10.155.12.0 255.255.255.0 10.155.12.188 10.155.12.188
1
10.155.12.188 255.255.255.255 127.0.0.1 127.0.0.1
1
10.255.255.255 255.255.255.255 10.155.12.188 10.155.12.188
1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1
1
224.0.0.0 224.0.0.0 10.155.12.188 10.155.12.188
1

Then have it pull two different variables (IP Addresses) from the file
and put them as printed char''s in another command line to be used with
the system() command. The end command would look something like
this...

system("route add x.x.x.x mask 255.0.0.0 y.y.y.y metric 1")

The x.x.x.x would be one IP Address obtained from the file, and
y.y.y.y would be the second. The Line in the file would be constant,
but the x.x.x.x and y.y.y.y would vary...

Any suggestions?



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]



"Rob" <ro******@yahoo.com> wrote in message
news:34*************************@posting.google.co m...

I am trying to write a program with VC++ 6.0 to read a txt file which
looks like this:

Network Destination Netmask Gateway Interface
Metric
0.0.0.0 0.0.0.0 10.155.12.1 10.155.12.188
1
10.155.12.0 255.255.255.0 10.155.12.188 10.155.12.188
1
10.155.12.188 255.255.255.255 127.0.0.1 127.0.0.1
1
10.255.255.255 255.255.255.255 10.155.12.188 10.155.12.188
1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1
1
224.0.0.0 224.0.0.0 10.155.12.188 10.155.12.188
1

Then have it pull two different variables (IP Addresses) from the file
and put them as printed char''s in another command line to be used with
the system() command. The end command would look something like
this...

system("route add x.x.x.x mask 255.0.0.0 y.y.y.y metric 1")

The x.x.x.x would be one IP Address obtained from the file, and
y.y.y.y would be the second. The Line in the file would be constant,
but the x.x.x.x and y.y.y.y would vary...

Any suggestions?

As always, any help is greatly appreciated.



You could create a class which resembles & stores that actual data records
you want to read. This class should of course have access functions as well
as an inserter and extractor operator. Use stream iterators & a collection
to read the records from a file and store them in the container. Then you
just have to iterate over the container accessing the respective information
you need to assemble the string.

If you need more help then post some code which you already have.

HTH
Chris


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


这篇关于IP地址,文件解析 - 帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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