1, with characters:
The ip address is char [4];
Char is 8 bits, but there are positive and negative points. (If you are worried that you can loop, such as -2 equivalence, 128+2, at least compiled in VC); A char[4] like that will do.
2. use int:
Int is 32, just an ip, so how to separate four ip subaddresses from an int? Let me give you an example. If you don't understand, send me a message:
100 1, 01kloc-0/,010/separate three hexadecimal:
Then let p = 100 1, 0 10 1, 01.
If p> 1 000,000,0000. then the first place of p is1,otherwise it is 0. Until this, subtraction, look at the second place, make a loop! Do it.
Yes, those 0 1 are the binary codes of your integer.
* * * Of course, if you directly know the conversion method between binary and decimal, you don't need my nonsense above.