How to increment an IP address in a loop? [C]
I know this is pretty simple for most of you but I am trying to increment
an ip address by +1 in a loop.
Example:
for(double ip = 1.1.1.1; ip < 1.1.1.5; ip++)
{
printf("%f", ip);
}
Basically all I am trying to do is increment the ip by +1 in a for loop. I
don't know what type of variable to store the ip in and don't know how to
increment it. Whenever I run the program I get an error saying that the
number has too many decimal points. I've also seen on the internet that
you have to store ip's in a character array, but you cannot increment a
character array (that I know of). What variable type should I store the ip
in/how should I approach this? Thank you.
No comments:
Post a Comment