>
>
>
V682. Suspicious literal: '/r'. It is p…


V682. Suspicious literal: '/r'. It is possible that a backslash should be used instead: '\r'.

The analyzer has detected a potential error when a forward slash is used.

It's easy to make a mistake mixing up the forward slash and backward slash characters.

For example:

if (x == '/n')

The programmer intended to compare the variable 'x' to the code 0xA (line feed) but made a mistake and wrote a forward slash. It results in the variable being compared to the value 0x2F6E.

This is the fixed code:

if (x == '\n')

Such a mistake is usually made when working with the following escape sequences:

  • newline - \n
  • horizontal tab - \t
  • vertical tab - \v
  • backspace - \b
  • carriage return - \r
  • form feed - \f
  • alert - \a
  • backslash - \\
  • the null character - \0

References: