you are right, and you are wrong, too. atoi("1234") would return 1234 atoi("Nashak") would return 0, because of the fact that N is NOT a number. i think one of the first checks in atoi() is something similar to isnumber(first character of string); if its not a number, it always returns 0, which is why atoi("-1234") = 0 have fun :-) Akuma the Raging Coder At 12:43 PM 10/3/97 -0700, you wrote: >If I'm not mistaken, atoi just returns 0 always. Like atoi("Nashak") = 0, >it just changes it to an integer. > >On Fri, 3 Oct 1997, Aaron Miller wrote: > >> I am writing a (rather lengthy) function in magic.c, called do_grasp. >> I followed the instructions on adding new commands in coding.doc, namely >> the argument part. Heres what I have >> >> int do_grasp(struct char_data * ch, char *argument, int cmd, int subcmd) >> { >> int argu; >> /* other declarations that are irrelevent snipped */ >> >> skip_spaces(&argument); >> one_argument(&argument, buf); >> argu = atoi(buf); /* i need an integer to work worth */ >> >> sprintf(buf, "Argument: %d\r\n", argu); >> >> /* snip rest of function, completely irrelevent */ >> } >> >> I always, no matter what, get 0. What am I doing wrong, here? I followed >> the instructions for using arguments as best I could. Thanks for >> any/all help. >> >> >> +------------------------------------------------------------+ >> | Ensure that you have read the CircleMUD Mailing List FAQ: | >> | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | >> +------------------------------------------------------------+ >> > > /-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=X=-=-=-=-=-=-=-=-=-=-=-\ > | Brian M. Williams | 02/02/83 | bmw@efn.org | > X=-=-=-=-=-=-=-=-=-=-=-=-=-=-=+=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=X > | Boccob the Uncaring, Lord of All Magic | Nashak Stonehand | > | accolademud.hermesnet.net 5000 | coyote.toon.org 6000 | > \=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-X-=-=-=-=-=-=-=-=-=-=-=/ > > > +------------------------------------------------------------+ > | Ensure that you have read the CircleMUD Mailing List FAQ: | > | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | > +------------------------------------------------------------+ > > +------------------------------------------------------------+ | "The poets talk about love, but what I talk about is DOOM, | | because in the end, DOOM is all that counts." - | | Alex Machine/George Stark/Stephen King, The Dark Half | | "Nothing is IMPOSSIBLE, Just IMPROBABLE" | | "Easier Said Than Done, But Better Done Than Said..." | +------------------------------------------------------------+ +------------------------------------------------------------+ | 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