Hello everybody . I have a text file , I want to compare ip with in line text
This is file text
Code:codeguru.com c++.com C#.com google.com c+++.com
And this is my code
Code:#include <iostream> #include <fstream> #include <string> #include <conio.h> using namespace std; string getip(string hostname) { //function get ip } void main () { string string_main="http://abc-xyz.com/www/~av.123.456.789.000?url.aspx/etc"; int count=0; string string_sub; ifstream infile; infile.open ("E:\\test.txt"); while(!infile.eof()) // To get you all the lines. { getline(infile,string_sub); // Saves the line in string_sub. // cout<<string_sub<<"\n"; // Prints our string_sub. if (!string_sub.empty()) { string temp=getip(string_sub); // get ip of string_sub on the text line by line size_t result = string_main.find( temp ); //check string_sub on the text file line by line, comparable to string_main if( result != string::npos ) // if found { count+=1; } } } infile.close(); //cout<< count <<"\n"; if (count != 0) { cout << "Found\n"; } else { cout << "Not found\n"; } getch(); }
Can you see it , How to create function get ip above ?
Thank you .




Reply With Quote
