Compilation error: missing terminating ' character

So I have a compilation error and was wondering if anyone could help me fix it!
I am using a arduino mega

so this is the highlighted error part :

Serial.print('

'); for(int i = 0; i < 3; ++i) { int val = EEPROM.read(4 + i); if(val < 16) Serial.print('0');

Serial.print(val, HEX); } Serial.print(' '); for(int i = 0; i < 64; ++i) { int val =

EEPROM.read(4 + 3 + i); if(val < 16) Serial.print('0'); Serial.print(val, HEX); if((i & 3) ==

  1. Serial.print(' '); } Serial.print(' '); }

and here is a screenshot of it:

Please insert the code using code tags. The images of the code are useless.

1 Like

i'm hoping this is better and im sorry for my lack of etiquette.

 Serial.print('
'); for(int i = 0; i < 3; ++i) { int val = EEPROM.read(4 + i); if(val < 16) Serial.print('0'); 
Serial.print(val, HEX); } Serial.print(' '); for(int i = 0; i < 64; ++i) { int val = 
EEPROM.read(4 + 3 + i); if(val < 16) Serial.print('0'); Serial.print(val, HEX); if((i & 3) == 
3) Serial.print(' '); } Serial.print(' '); }

i dont know if this helps or if im doing it correctly, im a newb just trying to get some help making this code work. thank u for any and all help!!

 Serial.print('

'); for(int i = 0; i < 3; ++i) { int val = EEPROM.read(4 + i); if(val < 16) Serial.print('0'); 

Serial.print(val, HEX); } Serial.print(' '); for(int i = 0; i < 64; ++i) { int val = 

EEPROM.read(4 + 3 + i); if(val < 16) Serial.print('0'); Serial.print(val, HEX); if((i & 3) == 

3) Serial.print(' '); } Serial.print(' '); }

i dont know if im doing it right or if this helps but u tell me!

Serial.print('

'); for(int i = 0; i < 3; ++i) { int val = EEPROM.read(4 + i); if(val < 16) Serial.print('0'); 

Serial.print(val, HEX); } Serial.print(' '); for(int i = 0; i < 64; ++i) { int val = 

EEPROM.read(4 + 3 + i); if(val < 16) Serial.print('0'); Serial.print(val, HEX); if((i & 3) == 

3) Serial.print(' '); } Serial.print(' '); }
  1. Please post complete code using the code tags. People should be able to try to compile your code and see the same error. I would advise you reformat you code to have only a single statement on each line. In the ide window use edit > auto format to make it easier to see what is going on.

  2. Post the complete error message. Click on the quotation marks at the top of the reply window and post the text after the blockquote >

That's an unholy mess. Take a look at the example code in the Arduino IDE. You'll see NONE of it is formatted like that.

First lesson…
The C class languages are heavily dependent on whitespace to process the source code structure.

So far you have obviously not absorbed that fact, nor have you followed suggestions from the helpers.

We can’t help you, if you don’t help yourself.

1 Like

i auto compiled it and than copied the whole error message and thanput it after the blockquote

C:\Users\Dell\AppData\Local\Temp.arduinoIDE-unsaved2024323-2376-1c1zvmf.zjdd\sketch_apr23a\sketch_apr23a.ino:197:15: error: missing terminating ' character
Serial.print('
^
C:\Users\Dell\AppData\Local\Temp.arduinoIDE-unsaved2024323-2376-1c1zvmf.zjdd\sketch_apr23a\sketch_apr23a.ino:198:92: error: missing terminating ' character
'); for(int i = 0; i < 3; ++i) { int val = EEPROM.read(4 + i); if(val < 16) Serial.print('0');
^~~
C:\Users\Dell\AppData\Local\Temp.arduinoIDE-unsaved2024323-2376-1c1zvmf.zjdd\sketch_apr23a\sketch_apr23a.ino: In function 'void dump()':
C:\Users\Dell\AppData\Local\Temp.arduinoIDE-unsaved2024323-2376-1c1zvmf.zjdd\sketch_apr23a\sketch_apr23a.ino:198:91: error: expected ')' before numeric constant
'); for(int i = 0; i < 3; ++i) { int val = EEPROM.read(4 + i); if(val < 16) Serial.print('0');
^
C:\Users\Dell\AppData\Local\Temp.arduinoIDE-unsaved2024323-2376-1c1zvmf.zjdd\sketch_apr23a\sketch_apr23a.ino: At global scope:
C:\Users\Dell\AppData\Local\Temp.arduinoIDE-unsaved2024323-2376-1c1zvmf.zjdd\sketch_apr23a\sketch_apr23a.ino:201:1: error: 'Serial' does not name a type
Serial.print(' ');
^~~~~~
C:\Users\Dell\AppData\Local\Temp.arduinoIDE-unsaved2024323-2376-1c1zvmf.zjdd\sketch_apr23a\sketch_apr23a.ino:202:1: error: expected unqualified-id before 'for'
for (int i = 0; i < 64; ++i) {
^~~
C:\Users\Dell\AppData\Local\Temp.arduinoIDE-unsaved2024323-2376-1c1zvmf.zjdd\sketch_apr23a\sketch_apr23a.ino:202:17: error: 'i' does not name a type
for (int i = 0; i < 64; ++i) {
^
C:\Users\Dell\AppData\Local\Temp.arduinoIDE-unsaved2024323-2376-1c1zvmf.zjdd\sketch_apr23a\sketch_apr23a.ino:202:25: error: expected unqualified-id before '++' token
for (int i = 0; i < 64; ++i) {
^~
C:\Users\Dell\AppData\Local\Temp.arduinoIDE-unsaved2024323-2376-1c1zvmf.zjdd\sketch_apr23a\sketch_apr23a.ino:209:1: error: 'Serial' does not name a type
Serial.print(' ');
^~~~~~
C:\Users\Dell\AppData\Local\Temp.arduinoIDE-unsaved2024323-2376-1c1zvmf.zjdd\sketch_apr23a\sketch_apr23a.ino:210:1: error: expected declaration before '}' token
}
^

exit status 1

Compilation error: missing terminating ' character

copied the whole error message

Good job.

Now where is the complete code posted using the code tags?

1 Like

i hope this works we'll see

#include <EEPROM.h>
#define CONSERVATIVE
int ioPin = 3;
#define BUFSIZE 200
unsigned char buf[BUFSIZE];
#define pullLow() pinMode(ioPin, OUTPUT)
#define pullHigh() pinMode(ioPin, INPUT)
unsigned char dbits[] = {
  0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 1, 0,
  1, 0, 0, 0, 1, 1, 1, 1,
  1, 0, 0, 0, 0, 0, 0, 0, 1,
  0, 0, 0, 0, 1, 0, 0, 0, 1,
  0, 0, 1, 1, 0, 0, 0, 0
};
unsigned char bits[][144] = {
  { 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    1, 0, 1, 0, 0, 0, 1, 0,
    0, 1,
    1, 0, 0, 0, 1, 0, 0, 0, 1,
    1, 0, 1, 0, 0, 1, 0, 1, 1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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0 }
};
unsigned char bval;
void wentLow() {
  bval = 1;
}
int readData(unsigned long int addr) {
  for (int i = 0; i < 8; ++i)
    dbits[50 + 9 + i] = (addr >> i) & 1;
  for (int i = 0; i < 8; ++i)
    dbits[50 + i] = (addr >> (i + 8)) & 1;
  for (int i = 0; i < 8; ++i)
    dbits[50 + 9 + 9 + i] = ((addr >> i) ^ (addr >> (i + 8)) ^ (0x1D >> i)) & 1;
  for (int i = 0; i < sizeof(dbits); ++i) {
    if (dbits[i] == 0) {
      pullLow();
      delayMicroseconds(16);
      pullHigh();
      delayMicroseconds(190);
    } else {
      pullLow();
      delayMicroseconds(16);
      pullHigh();
      delayMicroseconds(56);
      pullLow();
      delayMicroseconds(16);
      pullHigh();
      delayMicroseconds(112);
    }
  }
  pullLow();
  delayMicroseconds(16);
  pullHigh();
  bval = 0;
  attachInterrupt(1, wentLow, FALLING);
  unsigned int i = 0;
  while (digitalRead(ioPin) == HIGH && i++ < 32767) {
    //delayMicroseconds(20);
  }
  if (i == 32767)
    return false;
  delayMicroseconds(20);
  int hit = 0;
  for (int i = 0; i < 165; ++i) {
    buf[i] = 0;
    pullLow();
    delayMicroseconds(8);
    pullHigh();
    bval = 0;
    delayMicroseconds(184);
    buf[i] = bval;
    hit |= bval;
  }
  return hit;
}
int getByte(int off) {
  int i = 0, val = 0;
  for (; i < 8; ++i)
    val = (val << 1) | buf[13 + off * 9 + 7 - i];
  return val;
}
void open() {
  pinMode(ioPin, OUTPUT);
  digitalWrite(ioPin, LOW);
  pinMode(ioPin, INPUT);
  digitalWrite(ioPin, LOW);
  if (!readData(0x110))
    return;
  for (int i = 0; i < 4; ++i) {
    unsigned char val = 0;
    for (int j = 0; j < 8; ++j)
      val = (val << 1) | buf[22 + i * 9 + 7 - j];
    EEPROM.write(i, val);
  }
  for (int i = 0; i < 32 + 3; ++i)
    bits[0][50 + i] = buf[22 + i];
  for (int i = 0; i < 8; ++i) {
    bits[0][86 + i] = bits[0][50 + i] ^ bits[0][50 + 9 + i] ^ bits[0][50 + 18 + i] ^ bits[0][50 + 27 + i];
  }
  bits[0][86] ^= 1;
  bits[0][87] ^= 0;
  bits[0][88] ^= 1;
  bits[0][89] ^= 1;
  bits[0][90] ^= 1;
  bits[0][91] ^= 0;
  bits[0][92] ^= 1;
  bits[0][93] ^= 1;
  for (int i = 0; i < 4; ++i) {
    readData(0x412C + (i << 4));
    for (int j = 0; j < 4; ++j) {
      for (int x = 0; x < 4; ++x)
        EEPROM.write(4 + 3 + (i << 4) + (j << 2) + x, getByte((j << 2) + x));
    }
  }
  readData(0x124);
  for (int i = 0; i < 3; ++i)
    EEPROM.write(4 + i, getByte(i));
#ifdef CONSERVATIVE
  delay(100);
#endif
  for (int j = 0; j < 11; ++j) {
    for (int i = 0; i < sizeof(bits[j]); ++i) {
      if (bits[j][i] == 0) {
        pullLow();
        delayMicroseconds(16);
        pullHigh();
        delayMicroseconds(190);
      } else {
        pullLow();
        delayMicroseconds(16);
        pullHigh();
        delayMicroseconds(56);
        pullLow();
        delayMicroseconds(16);
        pullHigh();
        delayMicroseconds(112);
      }
    }
#ifdef CONSERVATIVE
    delayMicroseconds(2700);
#else
    delayMicroseconds(500);
#endif
  }
}
void setup() {
  Serial.begin(115200);
  dump();
}
void dump() {
  while (Serial.available())
    Serial.read();
  for (int i = 0; i < 4; ++i) {
    int val = EEPROM.read(i);
    if (val < 16)
      Serial.print('0');
    Serial.print(val, HEX);
  }
 Serial.print('
'); for(int i = 0; i < 3; ++i) { int val = EEPROM.read(4 + i); if(val < 16) Serial.print('0'); 
Serial.print(val, HEX);
}
Serial.print(' ');
for (int i = 0; i < 64; ++i) {
  int val =
    EEPROM.read(4 + 3 + i);
  if (val < 16) Serial.print('0');
  Serial.print(val, HEX);
  if ((i & 3) == 3) Serial.print(' ');
}
Serial.print(' ');
}
void loop() {
  if (Serial.available())
    dump();
  open();
}

@Delta_G

that worked!!

YESSSSSS! thank you soooo much it worked!!!! thank you thank you thank you !!

Sketch uses 6714 bytes (2%) of program storage space. Maximum is 253952 bytes.
Global variables use 2061 bytes (25%) of dynamic memory, leaving 6131 bytes for local variables. Maximum is 8192 bytes.

Do you understand why? I ask, because if you don't...you'll be back.

1 Like

I believe so I can't start a line in the middle of the parentheses I get that and all I needed was this one sketch so all the help thank you so much!

You can start a line in the middle of parentheses, just not in the middle of a character.

See:

and

1 Like

no. The issue is, two single quotes, ', should have between them a single character. In your case, you have

'crbbbbbbbbb'

where cr is a carriage return, and the bbbbbbbb after it is the space characters required for text alignment in the IDE.
(edited for visual clarity)

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.