Quick white space question

In C, does white space matter in array declarations? My array is giant and won't fit on one line. Can I put newlines in it?

Is this:

int myArray[4] = {123, 2, 45, 56,};

The same as this:

int myArray[4] = {123, 
2, 45, 


You can put space or line breaks wherever you like, just not between digits!

You can put any whitespace anywhere between tokens (tokens sometimes called lexemes). Certain tokens require at least one whitespace char between them to separate them (such as two identifiers or numbers), but otherwise whitespace is irrelevant.

define, #if etc are pre-processor directives - for these whitespace matters much more.

You can break a line without adding whitespace (useful for long #defines) with a backslash-newline combination

#define foo(a) \

Ok. So what exactly happens if you do this:

byte contstant_table [32] { 1,2, 3, 4, 5, 6, 7, 8, 9, 10, \
11,12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, \
27, 28, 29, 30, 31, 32}

I did this because my brain was still in perl-mode and I thought I needed the \'s. This compiled, but I have no idea what it did.

It misspelled "constant" and missed a semicolon. I'm surprised it compiled, but only because of the latter.

I mean besides those things. I mean specifically the backslashes.

It compiled with the backslashes and gave correct output. I guess backslashes are just ignored inside array declarations?

Backslashes at the end of a line are "line continuation" characters for the case where the line break WOULD be relevant. It essentially causes the newline to "cease to exist" as far as the parser is concerned. For example:

char *p = "this could be a \
long string";

Will end up setting p="this could be a long string", and the preprocessor examples people have posted parse as a single line. (as legal for a macro)

Technically, I guess that backslash before a newline causes the newline to be deleted at the token-input layer. There aren't many places in C where a newline token actually DOES anything meaningful, but in those places you can use the backslash to get rid of it.

Wow, so in my case, the backslashes caused the pre-processor to remove the newlines, but the compiler would have ignored the newlines anyway.

I will have to keep this in mind next time I enter a C obfuscation contest.

BetterSense: I will have to keep this in mind next time I enter a C obfuscation contest.

Keep in mind that slashes lead to obfuscation contests, which lead to straight jacks.