Re: Sscanf always returning 1

From: Brian (borlick@mines.edu)
Date: 11/07/02


Templar Viper wrote:
> <<snip>>
> retval, at the fourth line always returns 1. Weird enough, it does
> get in the loop. How can this occur?
> <<snip>>
>
> if ((sscanf(line, " %d %s %d ", t, flags, t + 2) == 3) && (bitwarning == TRUE)) {
>     log("WARNING: Conventional worldfiles detected. Please read 128bit.readme.");
>     exit(1);
>   } else if ((retval = sscanf(line, " %d %s %d ", t, flags, t + 2) == 3) && (bitwarning == FALSE)) {

You have some redundancy as well as too few parentheses.  First of all,
the issue that you asked about:

Too few parentheses.  To be more explicit, it executes like this right
now:

  (retval = (sscanf(line, " %d %s %d ", t, flags, t + 2) == 3))
  (retval = (3 == 3))
  (retval = 1)

But you're also being slightly redundant.  Try this:

   if ((retval = sscanf(line, " %d %s %d ", t, flags, t + 2)) == 3) &&
(bitwarning == TRUE)) {
     log("WARNING: Conventional worldfiles detected. Please read
128bit.readme.");
     exit(1);
   } else if (retval == 3 && bitwarning == FALSE) {

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT