"Newline in constant" error

I'm trying to declare a simple array with a long list so that later in my code I can identify the "badChar"s in my input, but every time I try to compile I get the "newline in constant" error. I read that this usually happens when someone forgets the closing " or ', but I checked carefully and each symbol has its own pair of single quotes with no extras.

char badChar[10] = {' ', '(', ')', ',', ';', ':', '<', '>', '@', '\'};

Does this have something to do with the symbols I'm trying to use? How can I get rid of this error?

Also, I know that the compiler was having issues when '[' and ']' were part of the array so I took them out, but if anyone can let me know of a way to include them I'd really appreciate it.
\ is used in escape sequences like \n, \t, etc. In your code it will think that \' should be treated as one character. For that reason you need to write \\ to mean the \ character.
Thank you! That worked perfectly!

If anyone knows how I could include square brackets in my array as well, I'd be really grateful.
You should be able to add the square brackets the same way you did with the other characters.
You would need to make badChar[12] though.
Oh! It's working now even though it was giving me errors about the brackets before. I must have made some typo earlier or something. Thanks for the help!
Topic archived. No new replies allowed.