Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am getting a list of IP associated with the current URL. I want to compare this list to a single IP address. I can compare one IP to another. However; how does one compare a list of IP's against one IP? Thank you.

C++
if (Newlength > 0) 
  { 
  sHost.resize(Newlength); 
  WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK, wsHost.c_str(), wsHost.length(), &sHost[0], Newlength, NULL, NULL);
  } 
  HOSTENT *pHostEnt2 = gethostbyname(sHost.c_str()); 
  if (!pHostEnt2) 
	{ 
	printf("\n   Unknown Website IP"); 
	} 
	else 
	{ 
	for 
	(char **addr = pHostEnt2->h_addr_list; *addr != NULL; ++addr) 
        { 
	printf("\n   Website IP: %s  \n", inet_ntoa(* (struct in_addr *) *addr)); 
	} 
	} 
	}
Posted
Comments
Sergey Alexandrovich Kryukov 10-Nov-11 21:52pm    
How much longer? You asked so many questions and should understand by now that you always need to explain where is your problem. Also, why not formatting the code so it would look clearly structured?
--SA

1 solution

As SA said, you really haven't shown a "problem". The code you posted only shows printing out some stuff, not comparing or what you want to compare to.

Hey, I have an idea. If you already have a loop to print out all the addresses, why not try a loop to compare each to what you are looking for instead of printing them.

There is no "compare this to a list of things" command or function, you have to write this yourself.

Or, you could research (using Google) some "Find" or "Lookup" functions available out there on the net. Of course, you'd have to arrange your list the way any function you identify would want it.

We'd really love to help but if you won't give clear problem statement or post relevant code to the problem you stated or give evidence that you either tried something yourself or researched it yourself, you're not likely to get any help.

I wouldn't be so strident in this message if it wasn't the 20th or 30th time you've done this.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900