Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Passing narrow string arguments to wide string functions or wide string arguments to narrow string functions can lead to unexpected and undefined behavior. Scaling problems are likely (see because of the difference in size between wide and narrow characters. (See ARR39-C. Do not add or subtract a scaled integer to a pointer) because of the difference in size between wide and narrow characters..) Because wide strings are terminated by a null wide character and can contain null bytes, determining the length is also problematic.

Because wchar_t and char are distinct types, many compilers will produce a warning diagnostic if an inappropriate function is used. (see See MSC00-C. Compile cleanly at high warning levels.).

Noncompliant Code Example (Wide Strings with Narrow String Functions) 

...