-
I want to ask, have you written it now?
-
I think you can compress this txt file first, compress it into a binary file, and then read this binary file to get each IP, and compare it with the IP benchmark library, so that the speed can be faster, no matter how many IP segments, you have to compare them one by one, or design an algorithm to reduce the number of redundant comparisons.
-
Seriously agree with the statement of the hero upstairs that the IP address is essentially just a unique int integer. It's a waste to compare characters, it's much easier to convert them to integers and compare them, so it's not so difficult to pick out what is within 100, 1000, and 1024 in a bunch of numbers.
-
You can open this file with Notepad (or other tools), look at the internal structure, and then write a read function yourself, which is just a data file with no interface functions.
If there is an interface function, of course you can.
In this case, you only need to read an IP address, use the strcmp() function to compare it with the benchmark, and see if the first few segments of the IP address are the same as the corresponding benchmark, and if so, it is the IP address of the corresponding region.
I don't know if you understand?
Or give a specific classification method and a so-called IP benchmark library in order to derive a more detailed implementation of the algorithm.
-
What does the benchmark library look like?
Don't use strcmp, the efficiency is too poor, convert the IP address to a 32-bit integer, and convert the IP segment in the benchmark database to a 32-bit integer.
To give you an example, the following procedure determines whether IP1 and IP2 fall within the range. Using the two library functions of inet aton() and ntohl(), my header file reference declaration is under linux, I don't know what header file to quote on vc, you can see the help in msdn.
You can refer to my program, first of all, the IP range in the IP benchmark library is all in and converted into integers and put in an array, and then start to read the txt file, each read, convert one into an integer, and then compare it with the range in the base library array, and then count, which is the most convenient.
#include
#include
#include
void main()
-
Legitimate steps to determine IP address: 1. First understand what IP address is, IP addresses are divided into Class A, Class B, Class C, Class D, and Class E. The IP address range of Class A is, Class B is, and Class C is then judged to be the length of the ID card.
In Class A IP addresses, the length of the network ID is 8 bits, the length of the host ID is 24 bits, and the subnet mask is class, which is suitable for medium-sized networks with a network ID length of 16 bits, a host ID length of 16 bits, and a subnet mask. Class C is suitable for small LANs with a network identity length of 24 bits, a host ID length of 8 bits, and a subnet mask. 3.
Finally, judge whether it is legitimate. Out of each legitimate IP address, there are four that start with ".""3 digits separated, each between 0 and 255, including 255.
An IP address is a uniform address format provided by the IP protocol. It assigns a logical address to each network and each host on the Internet to mask differences in physical addresses.
-
Use IP138** to query the public IP address.
#include
void clanchatdlg::getnetip()
setdlgitemtext(idc_net_ip,"Obtaining a public IP address");
cstring strsource;
cstring address;
cinternetsession mysession(null,0);
chttpfile* myhttpfile=null;
IP138 web page.
myhttpfile=(chttpfile*);Yin Jing reads the address of Wangchang Wheel.
while(myhttpfile->readstring(strsource))
addtolog(strsource);
int begin=0;
begin="[0);
if(begin!=-1) if found"["then look for it"]"The text in parentheses is your extranet IP
int end="]
m_internetip=,end-begin-1);Neboxin extracts the external network IP
setdlgitemtext(idc_net_ip,m_internetip);In the lower-left corner, the public IP address is displayed
-
Compare the IP address you enter with the IP address of the database, if it is in the database, it is legal, otherwise it is not legal.
First of all, a Class C has 254 addresses but there is always one as a gateway route, so there can be a maximum of 253 hosts. Then these hosts are public IP addresses. It can be done by setting up a LAN and using one IP. >>>More
Hello! I am very honored to have the opportunity to ask your questions. >>>More
However, it is clear that this is problematic because variable a is not assigned at all. >>>More
Stand-alone Internet access - after disconnecting the network (turning off the ADSL cat), refer to change:
It is not possible to know the exact address.
Only under special circumstances can an application be made to the public security organ or telecommunications. >>>More