I'm having a bit of trouble with making the buffer while making recover on PSET4. I have tried a couple different things, but I keep getting the same error regardless of the fix I try:

recover.c:25:40: error: excess elements in char array initializer [-Werror] unsigned char compare[] = {"0xff", "0xd8", "0xff"}; (The 0xd8 was underlined in the cs50 IDE)

I have tried to use both BYTE's, char arrays, unsigned char arrays (could someone please tell me if i have correctly understood this? - It is a char that denotes a number from 0 to 255), and char.


typedef uint8_t  BYTE;

BYTE buffer[512];
BYTE compare[] = {"0xff", "0xd8", "0ff"};

unsigned char

unsigned char buffer[512];
unsigned char compare[] = {"0xff", "0xd8", "0ff"};


char buffer[512];
char compare[] = {"0xff", "0xd8", "0ff"};

1 Answer 1


You're trying to put strings into byte/unsigned char/char arrays. Quotation marks denote a string. Since the values you're trying to put in are in fact, numbers, you must not use quotation marks.

Good luck with the problem set!

If this answers your question, please consider clicking the check mark button for forum maintenance.

  • Thank you very much! I didn't even think of that but it fixed my problem Jul 14, 2016 at 20:13

You must log in to answer this question.

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