Click here to Skip to main content
15,911,317 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Write a function to check that a given string is a valid IP address. An IP address is of the form a.b.c.d where a,b,c,d are numbers in the range 0-255 without a leading zero. You are not allowed to use any string methods like split, indexof, parseInt etc
Posted
Updated 14-Apr-10 21:16pm
v3

Given your tutors constraints, you have two options:

1) Loop through the string character by character and check it.
2) Use a Regex.

Given that simplicity of the task, I would guess that this is very early in your course? If so, go with the first option. Otherwise go with the second, but you will have to learn about regular expressions first.
 
Share this answer
 
You have to perform a simple iteration over the character array. It is very basic stuff for a software developer.
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900