whodunit.c:77:40: error: invalid digit 'f' in octal constant

if (triple.rgbtRed == 0000ff) whodunit.c:79:33: error: equality comparison result unused [-Werror,-Wunused-comparison]


Numbers starting with 0 are interpreted as octal (with digits 0-7). f is not a valid octal digit.

For hexadecimal numbers, you would use for example 0x0000ff. In this case, a 6-digit hexadecimal number makes little sense, as triple.rgbtRed is a single byte (being fully described by 2 digits).

edit: Some background

  • No prefix for decimal
  • Prefix 0 for octal (that's what you accidentally had)
  • Prefix 0x or 0X for hexadecimal
  • (Prefix 0b or 0B for binary - not available everywhere, C++14 standard includes it, C standard might follow)

There are also postfixes telling the compiler the type of the number, like a u for unsigned or l for long, so that you might have a literal 0xCAFEBABEul for an unsigned long int of value 0xcafebabe

  • thank you for helping me out.... Jun 14 '18 at 16:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .