How to Get a particular String From A File in c++? -


I have a file with data in a fixed layout. Each row has an IP address that I have to remove it and do something else in C ++.

A row looks like this:

T. 0.00057 / nodelist / 0 / DeviceList / 0 / $ NS3 :: WifiNetDevice / PHY / State / Tx NS3 :: WifiMacHeader (Statistics TODS = 0, FromDS = 0, Try again = 0, MoreData = 0 term / id = 0usDA = FF: FF: FF: FF: FF: FF, SA = 00: 00: 00: 00: 00: 01: BssID = 00: 00: 00: 00: 00: 01, Fragmentar = 0, Sequenumber = 0) NS3 :: LLC snap header (type 0x800) NS3 :: Ipv4Header (TOS 0x0 DSCP default ECN -ECT TTL 64 ID 0 protocol 17 offset (byte) 0 flags [no] length: 228 10.1.1.1 10.1.1.255) Ns3 :: UdpHeader (Length: 208 49153> 80) Payload (size = 200) NS3 :: WiFi Mactereler ()

The IP address to be removed is 10.1.1.1 .

There are 10,000 such lines in the file.

T. 0.00057 / nodelist / 0 / devicelist / 0 / $ NS3 :: WiFiNet device / fi / state / tx ns3 :: wifi mac header (data tds = 0, cds = 0 , More frg = 0, retry = 0, more data = 0 Dura Tion / ID = 0usDA = ff: ff: ff: ff: ff: ff, SA = 00: 00: 00: 00: 00: 01: 01, bssid = 00: 00: 00: 00: 00: 01, Fragmentar = 0, SeqNumber = 0) NS3 :: LlcSnapHeader (Type 0x800) NS3 :: Ipv4Header (TOS 0x0 DSCP Default ECN No-ECT TTL 64 ID 0 Protocol 17 Offset ) 0 Flags [Any] Length: 228 10.1.1.1> 10.1.1.255) NS3 :: UdpHeader (long : 208 49,153> 80) Payload (size = 200) NS3 :: WifiMacTrailer () R 0.0,02,87,433 / NodeList / 2 / DeviceList / 0 / $ NS3 :: WifiNetDevice / PHY / State / RxOk NS3: : WifiMacHeader (Figures TODS = 0, FromDS = 0, Try again = 0, MoreData = 0 duration / id = 0usDA = FF: FF: FF: FF: FF: FF, SA = 00: 00: 00: 00: 00:01, BSSID = 00: 00: 00: 00: 00: 01, FragNumber = 0, SeqNumber = 0) NS3 :: LlcSnapHeader (Type 0x800) NS3 :: Ipv4Header (TOS 0x0 DSCP Default ECN No- ECT TTL 64 ID 0 protocol 17 offset (bytes) 0 flags [none] Length: 228 10.1.1.1> 10.1.1.255) NS3 :: UDP header (length: 208 49153> 80) payload Doors = 200) ns 3 :: Waifaimaktrelr ()

How do I get these IP? Can anyone help me with code?

Usually, you will open the file in read mode and read each line. It appears that each line is in a certain pattern; Format. You can search a sub-string within each line and remove the IP address from it. For example: You can search for "[any] length" and after that you can read the IP address string (such as by looking for the next blank space and selecting the sub string between these sequences).

If you are using MFC, you can use CSTIOFile :: Watchstream to read each line. If you are not using MFC, you can refer to a file line by reading the line.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -