Re: Comment on trim string function please
On Jul 11, 5:55 am, Jack Klein <jackkl...@spam cop.netwrote:
<snip i = strlen(s)-1>
>
You are correct that size_t is an unsigned integer type, and can never
be negative. But that doesn't mean that underflowing it won't cause a
very serious problem. Consider:
>
<snip (unsigned long)(size_t)-1>
I don't see underflowing occuring anywhere in that code. Unsigned
integers can not underflow or overflow.
I do see your point, but your terminology was not correct.
Only signed integers can overflow, and when that happends the behavior
is not defined.
On Jul 11, 5:55 am, Jack Klein <jackkl...@spam cop.netwrote:
On Thu, 10 Jul 2008 10:56:18 -0700 (PDT), "swengineer...@ gmail.com"
i is of type size_t which I believe can't be negative?
You are correct that size_t is an unsigned integer type, and can never
be negative. But that doesn't mean that underflowing it won't cause a
very serious problem. Consider:
>
>
Compile and execute this and see what you get.
Compile and execute this and see what you get.
integers can not underflow or overflow.
I do see your point, but your terminology was not correct.
Only signed integers can overflow, and when that happends the behavior
is not defined.
Comment