i have a text file like this:

# Nmap 6.40 scan initiated Tue Dec 24 05:42:34 2013 as: nmap --open -oN 123.txt 10.0.5.0/24
Nmap scan report for 10.0.5.1
Host is up (0.63s latency).
Not shown: 992 closed ports, 6 filtered ports
PORT    STATE SERVICE
22/tcp  open  ssh
443/tcp open  https

Nmap scan report for 10.0.5.10
Host is up (0.048s latency).
Not shown: 997 filtered ports
PORT    STATE SERVICE
139/tcp open  netbios-ssn
443/tcp open  https
445/tcp open  microsoft-ds

Nmap scan report for 10.0.5.31
Host is up (1.0s latency).
Not shown: 982 closed ports, 6 filtered ports
PORT      STATE SERVICE
135/tcp   open  msrpc
139/tcp   open  netbios-ssn
445/tcp   open  microsoft-ds
912/tcp   open  apex-mesh
1110/tcp  open  nfsd-status
19780/tcp open  unknown
49152/tcp open  unknown
49153/tcp open  unknown
49154/tcp open  unknown
49155/tcp open  unknown
49156/tcp open  unknown
49158/tcp open  unknown

Nmap scan report for 10.0.5.65
Host is up (0.060s latency).
Not shown: 978 filtered ports
PORT      STATE SERVICE
80/tcp    open  http
135/tcp   open  msrpc
139/tcp   open  netbios-ssn
443/tcp   open  https
445/tcp   open  microsoft-ds
554/tcp   open  rtsp
902/tcp   open  iss-realsecure
912/tcp   open  apex-mesh
1801/tcp  open  msmq
2103/tcp  open  zephyr-clt
2105/tcp  open  eklogin
2107/tcp  open  msmq-mgmt
2869/tcp  open  icslap
3306/tcp  open  mysql
5357/tcp  open  wsdapi
10243/tcp open  unknown
49152/tcp open  unknown
49153/tcp open  unknown
49154/tcp open  unknown
49155/tcp open  unknown
49158/tcp open  unknown
49161/tcp open  unknown

Nmap scan report for 10.0.5.212
Host is up (1.0s latency).
Not shown: 975 closed ports, 8 filtered ports
PORT      STATE SERVICE
135/tcp   open  msrpc
139/tcp   open  netbios-ssn
443/tcp   open  https
445/tcp   open  microsoft-ds
554/tcp   open  rtsp
902/tcp   open  iss-realsecure
912/tcp   open  apex-mesh
1110/tcp  open  nfsd-status
2869/tcp  open  icslap
5357/tcp  open  wsdapi
8000/tcp  open  http-alt
10243/tcp open  unknown
49152/tcp open  unknown
49153/tcp open  unknown
49154/tcp open  unknown
49155/tcp open  unknown
49157/tcp open  unknown

# Nmap done at Tue Dec 24 05:50:26 2013 -- 256 IP addresses (6 hosts up) scanned in 472.20 seconds

i need to find matching word in it like

https found 4... etc.

can someone help me pls i'm just beginning to learn c++ and this is very urgent...thank you very much

What OS are you using? While there are many ways to do this using C++, the ubiquitous command line tool "grep" is literally made for this.

What Moschops said. Here is pseudo-code that you can use with C++ (or other programming language) to do this as well.

  1. Open file
  2. while not at end-of-file
  3. read line
  4. search for string (use strstr() in C/C++ for this).
  5. if found in #4, increment counter.
  6. goto #2.

Anyway, if you post some code we can help you sort it out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.