Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: minor edits

...

This is recommended because the C99 standard requires only the digit characters ('0' - '9') to have consecutive numerical values C99 N1401. ThusConsequently, operations that rely on expected values for plain character or plain wide character-typed expressions can lead to unexpected behavior.

...

This noncompliant code example attempts to determine if the value of a character variable is between 'a' and 'c' inclusive. However, since because the C99 standard does not require the letter characters to be consecutive or in alphabetical order, the check might not work as expected.

...

Code Block
bgColor#CCCCFF
langc
char ch = 't';
if ((ch == 'a') || (ch == 'b') || (ch == 'c')) {
  /* ... */
}

Exceptions

STR09-EX1EX0: Consecutive values for characters like a~z can be assumed on platforms where ASCII or Unicode is used. This recommendation is primarily concerned with platform portability, for example, if code is migrated from ASCII systems to non-ASCII systems.

...