0
         if (triple.rgbtRed == 255)
         {
            triple.rgbtRed = 0;
            triple.rgbtBlue = 100;
            triple.rgbtGreen = 60;
         }
        // write RGB triple to outfile
        fwrite(&triple, sizeof(RGBTRIPLE), 1, outptr);

I have this code but the error it shows me is this:

whodunit.c:77:40: error: invalid digit 'f' in octal constant if (triple.rgbtRed == 0000ff) ^

whodunit.c:79:36: error: use of undeclared identifier 'ffff'; did you mean 'feof'? triple.rgbtRed == ffff; ^~~~ feof

/usr/include/stdio.h:828:12: note: 'feof' declared here extern int feof (FILE __stream) __THROW __wur; ^ whodunit.c:79:33: error: comparison between pointer and integer ('int' and 'int ()(FILE )' (aka 'int ()(struct _IO_FILE *)')) [-Werror] triple.rgbtRed == ffff; ~~~~~~~~~~~~~~ ^ ~~~~

whodunit.c:79:33: error: equality comparison result unused [-Werror,-Wunused-comparison] triple.rgbtRed == ffff; ~~~~~~~~~~~~~~~^~~~~~~

whodunit.c:79:33: note: use '=' to turn this equality comparison into an assignment triple.rgbtRed == ffff; ^~ =

  • 1
    Possible duplicate of why cant i use the hexadecimal codes in my program? – Blauelf Jun 15 '18 at 10:06
  • Blau, I thought of that too, but it had an incomplete explanation of hex and octal representation. – Cliff B Jun 15 '18 at 10:08
  • Your error messages don't match the code you've shown us, so either you didn't save your source code before running make or you've compiled a different version than you are showing us. – curiouskiwi Jun 15 '18 at 10:39
  • I did save that code before compiling it. but shows me the same. I even did update50 for that reason but I am getting the same error...The I have changed my code and that's what I have posted above – Asha Thomas Jun 15 '18 at 11:05
  • sry, I got was I went wrong. Actually, I had two files of whodunit and in one of that code used hexa value and so I guess it was the reason of that error. But now it shows me this: clang: error: linker command failed with exit code 1 (use -v to see invocation) help me with this!!! – Asha Thomas Jun 15 '18 at 11:11
0

Hexadecimal numbers must start with 0x, as in 0x0000ff. Octal numbers start with just a 0, which is NOT part of the number. Octals also only use digits 0 to 7.

Also, if the error says that the line if (triple.rgbtRed == 0000ff) is in the file, I would ask if you saved the updated code, and saved it to the correct file in the correct directory before compiling it.

| improve this answer | |

You must log in to answer this question.

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