[Solved] error C2041: illegal digit ‘9‘ for base ‘8‘ | error C2059: syntax error: ‘bad suffix on number‘

Error log

Text

Octal value is out of range

1> E:\CProject\test12\Source. c(5,10): error C2041: illegal digit ‘8’ for base ‘8’

Hexadecimal value is out of range

1> E:\CProject\test12\Source. c(5,10): error C2059: syntax error: ‘bad suffix on number’
1> E:\CProject\test12\Source. c(5,10): error C2153: integer literals must have at least one digit
1> E:\CProject\test12\Source. c(5,13): error C2021: expected exponent value, not ‘;’
1> E:\CProject\test12\Source. c(5,10): warning C4244: ‘initializing’: conversion from ‘double’ to ‘int’, possible loss of data
1> Done building project “test12.vcxproj” – FAILED.

Screenshot (hexadecimal value exceeds the range)

Solution:

C2041 series error: this kind of number, which is generally octal or hexadecimal, is out of range
for example:

  1. 09; because there is no 9 in octal
  2. 0xq; because hex doesn’t have the q character.

This requires us to carefully check whether the relevant figures exceed the range.

Read More: