Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - In C language, how do you compare IP addresses? For example: 192.168.1.1 is changed to: 192.168.001.001. How do you write code? Or is there anything else that can be done?
In C language, how do you compare IP addresses? For example: 192.168.1.1 is changed to: 192.168.001.001. How do you write code? Or is there anything else that can be done?

Because each segment of the IP address must be up to 3 digits

So, define a string "192.168.1.1" and for loop the entire string.

Separated by '.', if there is one character before '.', add two 0s, and if there are two characters, add 1 0.

The general idea is like this