2

Im trying to declare an array of bytes so I can go through them and use each one of them seperatly. This is the array

const BYTE keybyte[] = {
    0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
    0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
    0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57 0x58,
    0x59, 0x5A, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
    0x36, 0x37, 0x38, 0x39, 0x25, 0x27, 0x26, 0x28,
    0x0D, 0x20, 0x10, 0x11, 0x12, 0x18};

For some reason when I compile it gives me these errors :/

error C2143: syntax error : missing '}' before 'constant'
error C2143: syntax error : missing ';' before 'constant'
error C2059: syntax error : 'constant'
error C2143: syntax error : missing ';' before '}'
error C2059: syntax error : '}'

I dont understand because if I replace it with

const BYTE keybyte[] = {0,0,0,0};

it works perfectly fine with no errors :/?

2 Answers 2

12

You are missing a comma between 0x57 and 0x58.

Sign up to request clarification or add additional context in comments.

2 Comments

wow... i so dumbbbb but thankyou really iv honestly bin stuck on it for a bout 15 minutes :p and i never thought i missed a comma.
It was pretty immediately visible when you look at the formatted code here on SO -- there's a big dent on the right :-)
2

Alexander Gessler is right - comma is missing. Next Time try compile file with gcc and clang. It will guide you to problem resolution:

For file test.h containing:

const char keybyte[] = {0x41, 0x42, 0x43 0x44, 0x45, 0x12, 0x18};

when I try GCC:

test.h:1:42: error: expected ‘}’ before numeric constant

Compilers parser says, the syntax is wrong on the line 1 and the character 42:

When I ask clang, I get even better output:

clang test.h
test.h:1:42: error: expected '}'
const char keybyte[] = {0x41, 0x42, 0x43 0x44, 0x45, 0x12, 0x18};
                                         ^

so I see where the problem is.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.