Discussion: Strange I/O error
Afficher un message
Vieux 13/04/2008, 13h02   #4
Harald van Dijk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Strange I/O error

On Sun, 13 Apr 2008 10:21:48 +0000, Bartc wrote:
> But for this code, n needs to be unsigned, in which case the 'if (n<0)'
> should be a compilation error.


Huh? If n is unsigned, it will never be less than zero, but why would
checking that anyway result is a compilation error? What if you're
dealing with a typedef that may be signed or unsigned, depending on the
system, and you want to check that a value is in the range of [0 .. 10]?
It shouldn't be and isn't an error to check
if (n < 0 || n > 10) /* handle error */

(This thread was posted to comp.os.linux, but according to my ISP, it
doesn't exist. Newsgroups set to comp.lang.c only.)
  Réponse avec citation
 
Page generated in 0,04425 seconds with 9 queries