为什么我的编译器期望';' 在'}'标签之前?

kin*_*onz 2 c++

#include <iostream>
#include <string>
#include <cstring>
#include <vector>

using namespace std;

struct node {
   int number;
   string name;
   node* next;
};

int hash(string dna) {
   int i, sum=0;
   for (i=0; i<dna.size(); i++) {
      if (dna[i]=='A') {
      }
      else if (dna[i]=='C') {
         sum+=1;
      }
      else if (dna[i]=='G') {
         sum+=2;
      }
      else {
         sum+=3;
      }
   }
   cout << "Hash sum is " << sum << endl;
   return sum;
}

int main() {
   //input
   int dnalength, sublength;
   cin >> dnalength >> sublength;
   string sequence;
   cin >> sequence;
   //Declare array
   vector <node*> list(sublength*3+1);
   cout << "The list size is " << list.size() << endl;
   //Storing all substrings
   int index;
   for (index=0; index+sublength-1<dnalength; index++) {
      string temp = sequence.substr(index, sublength);
      cout << "Current substring is " << temp << endl;
      int value = hash(temp);
      if (list[value]==NULL) {
         //cout << "Null activated " << endl;
         //Node declaration
         node* ptr;
         ptr = new node;
         ptr->number=1;
         ptr->name=temp;
         ptr->next=NULL;

         list[value]=ptr;
      }
      else {
         node* ptr=list[value];
         while (ptr->next!=NULL) {
            if (ptr->name==temp) {
               ptr->number++;
               goto location;
            }
            ptr=ptr->next;
         }
         if (ptr->name==temp) {
            ptr->number++;
            goto location;
         }
         node* newptr;
         newptr = new node;
         newptr->number=1;
         newptr->name=temp;
         newptr->next=NULL;

         ptr->next=newptr;
location:
      }
      cout << "Success 1 loop " << endl;
   }
   cout << "Debug @ 3: " <<list[3]->name << list[3]->number << endl;
   cout << "Debug @ 3: " <<(list[3]->next)->name << (list[3]->next)->number << endl;

   int numofsub;
   cin >> numofsub;

   return 0;
}
Run Code Online (Sandbox Code Playgroud)

预期';' 之前'}'令牌??? 在第80:7行,这是这一部分

         ptr->next=newptr;
location:
      }
Run Code Online (Sandbox Code Playgroud)

我在我的智慧结束...我尝试了很多方法来调试,问题与GOTO功能有关,但我真的看不出任何问题!

ybu*_*ill 8

你没有.更换:

      ptr->next=newptr;
location:
   }
Run Code Online (Sandbox Code Playgroud)

      ptr->next=newptr;
location:;                   // <-- empty statement
   }
Run Code Online (Sandbox Code Playgroud)

这是语言的语法:语句必须遵循标签,至少是空标签.