Brain Fart
If I have a C style string and I need to count the number of octets (numbers between the decimals) of an IP address, what would be a good idea of that?
I already have to count the number of '.' (dots) in it, but I need to make sure there are 4 octets. So if someone enters 128.145.0. that it picked up as having correct number of dots but incorrect octets.
I was thinking along the lines of checking the str[i - 1] and str[i + 1] if str[i] == '.', but that doesn't work for bounds.
Any ideas would be awesome, Thanks all.
I already have to count the number of '.' (dots) in it, but I need to make sure there are 4 octets. So if someone enters 128.145.0. that it picked up as having correct number of dots but incorrect octets.
I was thinking along the lines of checking the str[i - 1] and str[i + 1] if str[i] == '.', but that doesn't work for bounds.
Any ideas would be awesome, Thanks all.
