Weeding out Hexadecimal IP address

Discussion in 'C++' started by Slain, Dec 12, 2007.

  1. Slain

    Slain Guest

    I need to validate to ensure that the user is not entering IP address
    in Hexadecimal form. Is there some way to check for it?

    The user would probably enter it in 0x form. Hence the only solution
    which comes to my mind is to look for 'x' int the string and if so
    declare it invalid. Any other ideas?

    Thanks
     
    Slain, Dec 12, 2007
    #1
    1. Advertising

  2. Slain wrote:
    > I need to validate to ensure that the user is not entering IP address
    > in Hexadecimal form. Is there some way to check for it?


    The usual and the simplest way is to try converting and if it fails,
    tell the user (and ask to re-enter).

    > The user would probably enter it in 0x form. Hence the only solution
    > which comes to my mind is to look for 'x' int the string and if so
    > declare it invalid. Any other ideas?


    I am not sure I grasp your 'x' idea...

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Dec 12, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dmitry Bond.

    Hexadecimal formatting with leading zeros?!

    Dmitry Bond., Oct 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    8,087
    Oliver Sturm
    Oct 13, 2005
  2. Victor Hannak
    Replies:
    0
    Views:
    7,498
    Victor Hannak
    Feb 20, 2004
  3. Mad Scientist Jr
    Replies:
    3
    Views:
    803
    bloomfield
    Jun 21, 2004
  4. xeon123 mailinglist

    get object by hexadecimal address in jstack

    xeon123 mailinglist, Aug 10, 2011, in forum: Java
    Replies:
    0
    Views:
    256
    xeon123 mailinglist
    Aug 10, 2011
  5. xeon123 mailinglist

    get object by hexadecimal address in jstack

    xeon123 mailinglist, Aug 10, 2011, in forum: Java
    Replies:
    0
    Views:
    281
    xeon123 mailinglist
    Aug 10, 2011
Loading...

Share This Page