HELP ME TO SOLVE-a function-definition is not allowed here before '{' token

I AM BEGINNER SO PLZ HELP ME TO SOLVE THIS PROGRAM
ERROR-:a function-definition is not allowed here before '{' token
I AM FACING IT IN VOID LOOP
char c;
int M1 =3;
int M2 =5;
int M3 =7;
int M4 =9;
String readString;
void setup() {
** //set all the motor control pins to output**
** pinMode (M1, OUTPUT);**
** pinMode (M2, OUTPUT);**
** pinMode (M3, OUTPUT);**
** pinMode (M4, OUTPUT);**
** Serial.begin(9600);**
}
void loop() {
** while(Serial.available()){**
** char c = Serial.read();**
** readString+=c;**
** }**
** if(readString.length() > 0) {**
** Serial.println(readString);**
** if(readString == "U"){**
** digitalWrite(M1, HIGH);**
** digitalWrite(M2, HIGH);**
** digitalWrite(M3, HIGH);**
** digitalWrite(M4, HIGH);**
** }**

** if(readString == "D"){**
** digitalWrite(M1, LOW);**
** digitalWrite(M2, LOW);**
** digitalWrite(M3, LOW);**
** digitalWrite(M4, LOW);**
** }**
** if(readString == "L"){**
** digitalWrite(M2, HIGH);**
** digitalWrite(M4, HIGH);**
** void loop(){**
** digitalWrite(M1, HIGH);**
** digitalWrite(M3, HIGH);**
** delay(200);**
** digitalWrite(M3, LOW);**
** digitalWrite(M1, LOW);**
** delay(200);**
** }**
** }**

** if(readString == "F"){**
** digitalWrite(M3, HIGH);**
** digitalWrite(M4, HIGH);**
** void loop(){**
** digitalWrite(M1, HIGH);**
** digitalWrite(M2, HIGH);**
** delay(200);**
** digitalWrite(M1, LOW);**
** digitalWrite(M2, LOW);**
** delay(200);**
** }**
** }**
** if(readString == "B") {**
** digitalWrite(M1, HIGH);**
** digitalWrite(M2, HIGH);**
** void loop( ) {**
** digitalWrite(M3, HIGH);**
** digitalWrite(M4, HIGH);**
** delay(200);**
** digitalWrite(M3, LOW);**
** digitalWrite(M4, LOW);**
** delay(200);**
** }**
** }**
** if(readString == "R") {**
** digitalWrite(M3, HIGH);**
** digitalWrite(M4, HIGH);**
** void loop( ) {**
** digitalWrite(M1, HIGH);**
** digitalWrite(M2, HIGH);**
** delay(200);**
** digitalWrite(M1, LOW);**
** digitalWrite(M2, LOW);**
** delay(200);**
** }**
** }**

How many loop() functions can you have in one Arduino program ?
How many have you got ?

Please read the guidelines about how to post code - put it inside code tags!

It appears you do not have the closing bracket '}' for your loop() definition. Use the auto format function in the IDE to format your code and you will see it.

Delta_G:
you can't have two functions named loop.

Sorry to be nitpicking, but that is not true.

You only can't have two functions named loop that take no parameters.
Having more than one function named loop is no problem but granted confusing.

void setup() {
  Serial.begin(250000);
}
void loop() {
  static bool printed;
  if (!printed) {
    printed = true;
    Serial.println(F("loop()"));
    loop(4);
    loop("abcd");
    loop(F("progmem"));
    Serial.println();
  }
}
void loop(uint8_t x) {
  Serial.print(F("loop("));
  Serial.print(F("uint8_t "));
  Serial.print(x);
  Serial.println(F(")"));
}
void loop(const char* x) {
  Serial.print(F("loop("));
  Serial.print(F("char* \""));
  Serial.print(x);
  Serial.println(F("\")"));
}
void loop(const __FlashStringHelper* x) {
  Serial.print(F("loop("));
  Serial.print(F("F(\""));
  Serial.print(x);
  Serial.println(F("\"))"));
}
loop()
loop(uint8_t 4)
loop(char* "abcd")
loop(F("progmem"))

Overloading of functions works with loop just as with any other name,
to the compiler there is nothing special about loop.

I don't somehow think that the OP is ready for function overloading just yet.

UKHeliBob:
I don't somehow think that the OP is ready for function overloading just yet.

Obviously he is not. :wink:

It was just a counterexample to rebut the claim "you can't have two functions named loop.".

I would not use overloading loop aside from obfuscation or riddle-code.

Delta_G:
I will in the future start saying, "You can't have two functions with the same name and the same signature" ...

Isn't the name part of the signature? If so, you can say it more precisely: ""You can't have two functions with the same signature". ;D

You seem to have missed the smiley at the end of my post.