Expected } at end of input

It keeps putting up the error even though i have tried to troubleshoot to fix the problem.

Arduino: 1.8.2 (Mac OS X), Board: “Arduino/Genuino Uno”

/Users/blank/Documents/Arduino/SD_Data/SD_Data.ino: In function ‘void setup()’:
SD_Data:63: error: expected ‘}’ at end of input
}
^
SD_Data:63: error: expected ‘}’ at end of input
SD_Data:63: error: expected ‘}’ at end of input
SD_Data:63: error: expected ‘}’ at end of input
SD_Data:63: error: expected ‘}’ at end of input
exit status 1
expected ‘}’ at end of input

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

    #include <SD.h>

    File myFile;
    File myData;
   File file;
    void setup()
    {
      Serial.begin(9600);
      Serial.print("Initializing SD card...");
     
      if (!SD.begin(4)) {
        Serial.println("initialization failed!");
        return;
      }
      Serial.println("initialization done.");
     
      if (SD.exists("num.txt")) {
      }
      else
      {
      myFile = SD.open("num.txt", FILE_WRITE); //TENTAR WRITE AND READ
      if (myFile) {
        Serial.print("Writing...");
        myFile.println("0");
        myFile.close();
        Serial.println("Done.");
      } else {
       
       int num = 0;
        if (myFile.available()) {
          num = myFile.parseInt();
          Serial.println(num);
          
        num++;
       int num2 = num;
        // close the file
        myFile.close();
      } else {
         // if the file didn't open, print an error:
        Serial.println("error opening test.txt");
      
     
      if (SD.exists("num.txt")) {
      SD.remove("num.txt");
      myFile = SD.open("num.txt",FILE_WRITE);
       if (myFile) {
        Serial.print("Writing...");
       // close the file:
        myFile.close();
        Serial.println("Done.");
      } 
      else 
      {
        Serial.println("Error opening num.txt");
      }


  void loop();
{
}

void loop();oops

If you indented properly, you'd see the other problem.

Count your opening braces and closing braces. That error means you're missing a } somewhere. I think at the end of setup, but count through them to be sure. Format the code to line up the { and } that match and you'll find it.

The error code is

Arduino: 1.8.2 (Mac OS X), Board: “Arduino/Genuino Uno”
SD_Data:8: error: expected unqualified-id before ‘{’ token
{Serial.begin(9600);
^
exit status 1
expected unqualified-id before ‘{’ token

#include <SD.h>
 int x = 0;
    File myFile;
    File myData;
   File file;
    void setup();
    
      {Serial.begin(9600);
      {Serial.print("Initializing SD card...");
     
      if (!SD.begin(4)); {
        Serial.println("initialization failed!");
        return;
      }
      {Serial.println("initialization done.");
     
      if (SD.exists("num.txt")) {
      }
      else
      {
      myFile = SD.open("num.txt", FILE_WRITE); //TENTAR WRITE AND READ
      if (myFile) {
        Serial.print("Writing...");
        myFile.println("0");
        myFile.close();
        Serial.println("Done.");
      } else {
       
       int num = 0;
        if (myFile.available()) {
          num = myFile.parseInt();
          Serial.println(num);
          
        num++;
       int num2 = num;
        // close the file
        myFile.close();
      } else {
         // if the file didn't open, print an error:
        Serial.println("error opening test.txt");
      
     
      if (SD.exists("num.txt")) {
      SD.remove("num.txt");
      myFile = SD.open("num.txt",FILE_WRITE);
       if (myFile) {
        Serial.print("Writing...");
       // close the file:
        myFile.close();
        Serial.println("Done.");
      } 
      else 
      {
        Serial.println("Error opening num.txt");
      
      
      
      }

       void loop();
  {
++x;
  }
void setup();

Big oopsie there. Can you spot it? Go compare with any of the example codes and see if you can spot the difference.

You sure picked up a lot of extra opening curly braces in there. IF you don't know what those are for, then you should go spend an hour or two with a good basic C++ tutorial and learn. They're not for just sprinkling throughout the code to make it pretty. They serve a specific purpose. You need to educate yourself on what that purpose is.

void loop();

Same oopsie here.

void setup(); <------<<<< get rid of ;

Edit
void loop(); <-------<<<<

Use CTRL T to format your sketches.

.

larryd:
void setup(); <------<<<< get rid of ;

If i do that i get the error

Arduino: 1.8.2 (Mac OS X), Board: “Arduino/Genuino Uno”

/Users/gkrier/Documents/Arduino/SD_Data/SD_Data.ino: In function ‘void setup()’:
SD_Data:63: error: expected ‘}’ at end of input
}
^
SD_Data:63: error: expected ‘}’ at end of input
SD_Data:63: error: expected ‘}’ at end of input
SD_Data:63: error: expected ‘}’ at end of input
SD_Data:63: error: expected ‘}’ at end of input
SD_Data:63: error: expected ‘}’ at end of input
SD_Data:63: error: expected ‘}’ at end of input
exit status 1
expected ‘}’ at end of input

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

void loop(); <-------<<<<

Use CTRL T to format your sketches.

.

Yes those errors are related to all the extra { you put in your code.

Did you do like I said and go read a C++ tutorial and learn how the { and } are supposed to work? No, you didn't. You haven't had time. If you'll do that then it will help you a lot. You seem to have very little clue about how the language works. It is really had to help someone in that condition. If you're not willing to put in a little time learning, then why should we waste our time going over your code?

"If you're not willing to put in a little time learning, then why should we waste our time going over your code?"

Listen to Delta_G

.