Re: [CODE] More arguments :(

From: Gary Barnett (gbarnett@POLARNET.COM)
Date: 10/04/97


On Saturday, October 04, 1997 11:58 AM, Aaron Miller
[SMTP:Tarus50@concentric.net] wrote:
> Ok, heres the code
>
> skip_spaces(&argument);
> one_argument(argument, buf);
> argu = atoi(buf);
>
> sprintf(buf, "Numerical Argument: %d", argu);
> send_to_char(buf, ch);
>
>
> Now, I know very well what atoi does. I want to print 0 if its not
> a number, or otherwise print the number. It is printing 0 always.
> Btw argu is an int.
>

int is_number(char *str) {
  while (*str)
    if (!isdigit(*(str++)))
      return 0;
  return 1;
}

(might be in interpreter.c already)

  int argu=0;

  skip_spaces(&argument);
  one_argument(argument, buf);
  if (*buf && is_number(buf))
     argu = atoi(buf);
  sprintf(buf, "Numerical Argument: %d", argu);
  send_to_char(buf, ch);

--Mallory

I can picture in my mind a world without war, a world without hate.
And I can picture us attacking that world, because they'd never
expect it.     - Jack Handey


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



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