[...]
But if you shift unsigned integers, you *know* what you'll get on
*any* (conforming) implementation. "It works on *my* system" is generally regarded as a poor argument. ;-)The two types of applications I can think of (off the top of my head) that require shifting and have no excuse for not being portable are communications, cryptography and numeric translation. Other than that, I guess it's used mostly for I/O, which doesn't always have to be portable.
"Undefined behavior" can be *anything*. It can format your hard drive, start WWIII, make demons fly from your nose, or do exactly what you expect.
[...]
I don't think I snipped anything...?
Even better: strncat is guaranteed to terminate the destination string, but strncpy is not. And strncat may actually append n+1 characters to the destination string, while strncpy will never write more than n.
Regards,
-=Dave