Re: [World Editors] Dikued

From: Daniel Koepke (dkoepke@CALIFORNIA.COM)
Date: 03/16/98


On Mon, 16 Mar 1998, AxL wrote:

->fgets(wstr, RE_MAXSTRLEN, stdin);
->
->        A simple thing to strip the newline is below, but if there's an
->alternate to putting that after every fgets() call for user input, I'd
->like to know. :)
->
->if (*wstr2)
->   wstr2[strlen(wstr2) - 1] = '\0';

Of course there's an alternate:

  void mfgets(char * buf, size_t len, FILE * fp)
  {
    fgets(buf, len, fp);
    if (*buf)
      buf[strlen(buf) - 1] = '\0';
  }

And replace all the calls of "fgets" with "mfgets" (simple search and
replace; except for the one call in mfgets, of course).  Why does it
use "wstr2", anyway?  If you load into "wstr", why do you copy it to
"wstr2"?


-dak


     +------------------------------------------------------------+
     | 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/15/00 PST