"error: expected primary-expression before '}' token" in arduino program

I came to encounter this error and can't get rid of it.

Design_Project.ino (14.7 KB)

You didn’t go from zero to 14kB of code, so what was the last change you made?

More members will see your code if posted properly. Read the how get the most out of this forum sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code. If the code is too large to post it can be attached. Better yet, make a minimal verifiable program that shows the problem.

Your image of the error messages is hard to read. Please include the error message as text. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags.

TheMemberFormerlyKnownAsAWOL:
You didn’t go from zero to 14kB of code, so what was the last change you made?

No change please view the code

I can’t view the code on my phone.

Please tell me you didn’t write 14kB of code and then hit “compile”

Also, please post (all of) the error message, not a picture (of part) of the error message.

Please tell me you didn’t write 14kB of code and then hit “compile”
Is that a problem. If yes, why?
And the pic of error I posted is all of it
Following I’m posting the error copied by pressing the Copy error messages option in Arduino IDE:
"Arduino: 1.8.13 (Windows 10), Board: “Arduino Uno”

C:\Users\159fa\Documents\Arduino\Design_Project\Design_Project.ino: In function ‘int DTMF()’:

Design_Project:212:9: error: expected primary-expression before ‘}’ token

}

^

C:\Users\159fa\Documents\Arduino\Design_Project\Design_Project.ino: In function ‘char CorrectPasscode()’:

Design_Project:330:9: error: expected primary-expression before ‘}’ token

}

^

exit status 1

expected primary-expression before ‘}’ token

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.
"

I guess the label "ContinueWhile:" is not allowed on that line. I moved it outside the "switch" and the "if" blocks, and it compiles wthout errors.

     }
      // Switch statement ends
      break;
      // ContinueWhile:  // REMOVE THIS
    }
    // If statement ends
  }
ContinueWhile:           // ADD THIS
  // While loop ends
  return DTMFvalue;
}

Is that a problem. If yes, why?

You just found out why.

I took a look at your code on my laptop.

It’s got too many comments, it’s got too many declarations of pin numbers, it’s got too many methods to read the DTMF, and worst of all, it’s got too many gotos.

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

For most people, one goto is too many gotos. There are other, and usually better ways.

TomGeorge:
Please read the post at the start of any forum , entitled “How to use this Forum”.
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

It’s too big for that.

It’s too big, full-stop.

C++ does not usually use labels or go-to. We use functions and function calls.

Hi,

TheMemberFormerlyKnownAsAWOL:
It's too big for that.

It's too big, full-stop.

With that in mind.
A question for @fayiz159 , did you develop your code in stages?
That is write code;

  • Just to get the DTFM working.
  • Just to get the LCD working.
  • Just to get the Password Recogition working.

THEN when each stage works, finally combine them one at a time?
During your code writing when did this error occur?
Did you backup your code as you went so if a problem like this occurred, you could go back to a previous version and check your code?
Tom... :slight_smile:

fayiz159:
No change please view the code