Re: Bounds Checking

From: Peter Ajamian (pajamian@access1.net)
Date: 08/19/99


Chuck Carson wrote:

> I am having a week long brain fart.... So excuse me if this
> is newbie.
>
> I need to do some bounds checking where the valid values
> are the number 0, and the lower case letters a-z. (upper
> case letters are converted prior to entering this function so
> I do not need to worry about that)
>
> I currently use (if arg && *arg) but this is letting thru
> values such as -1.
>
> This is in medit, to some additional menus I am adding.
>
> Is there a more thorough method of doing this?

Try something like the following (untested)...

if (strcspn(arg, "0abcdefghijklmnopqrstuvwxyz")) {
  send_to_char("Invalid entry, try again: ", ch);
  return;
}

Regards,


Peter


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST