Compiler error: expected declaration before '}' token

Here's my code:

/* Erica
4/28/15
Sketch to randomly display gibberish */

char*messages [] = {
         "My name is Erica",
         "Professor is the best",
         "I like cheese",
         "My cat distracts me from work";
}
void setup() 
{
Serial.begin (9600);
}

void loop() 
{
int delayPeriod = random(2000,8000);
delay (delayPeriod);
int messageIndex = random(4);
Serial.println (messages[messageIndex]);

}

And here's the error messages I'm getting:

GibberishSketch_apr28a.ino:9:41: error: expected '}' before ';' token

GibberishSketch_apr28a.ino:10:1: error: expected declaration before '}' token

Sorry for being a goofy noob, it must be a silly error. Thanks

The errors you are receiving are because of the semicolon on line nine (the last entry of the array).

Broken down the error states that at character 41 on line 9 (9:41), it expected to encounter the closing braces '}' before the semicolon ';'. Relocating the offending character to after the closing brace will allow you code to compile.

char*messages [] = {
         "My name is Erica",
         "Professor is the best",
         "I like cheese",
         "My cat distracts me from work"
};
1 Like

Thank you! :grinning: