In the line you indicated, temp
needs to be used because it's giving you information about the current number being read in (basically it's either -1 if it was a dot or the accumulated number if it was a number : temp = 10*temp + (ch-'0');
).
Obviously, you can't just be looking at ch
because then you'd have no way to check if the number was too high (IP-type numbers need to be from 0 to 255).