And use uint8_t (or int8_t) instead of char.
Posted Jun 22, 2011 21:49 UTC (Wed) by samroberts (guest, #46749)
Posted Jun 22, 2011 22:19 UTC (Wed) by dgm (subscriber, #49227)
So, if you plan to do arithmetic on characters, better cast them to int or unsigned char, or whatever type has the properties you need for your operations.
Posted Jun 23, 2011 4:18 UTC (Thu) by eru (subscriber, #2753)
Not just arithmetic. Even indexing an array with a char value will bite the unwary.
Posted Jun 23, 2011 8:48 UTC (Thu) by kris.shannon (subscriber, #45828)
Posted Jun 23, 2011 12:13 UTC (Thu) by dgm (subscriber, #49227)
Posted Jun 23, 2011 15:27 UTC (Thu) by jani (subscriber, #74547)
"In all cases c is an int, the value of which must be representable as an unsigned char or must equal the value of the macro EOF. If the argument has any other value, the behaviour is undefined."
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds