简体   繁体   中英

Primary expression C++ error

I have to write some programs for a class final and I'm running into an error that I can't figure out. I have checked the syntax in this program many times and it isn't very long so I don't know why I can't find it. When I try and compile, I get an error that says "expected primary-expression before '}' token". It says it's in line 23. Can anyone shed some light on what might be going on?

#include <iostream>
using namespace std;

int main()
{
    int sumOfPrimes = 2;

    for (int x=3; x<2000000; x++)
    {
        for (int y=2; y<x; y++)
        {
            if (x % y == 0)
            {
                goto break1;
            }
        }
        sumOfPrimes += x;
        break1:
    }

    cout << sumOfPrimes << endl;

    return 0;
}

You need to add a statement after a label. The null statement ; works fine:

break1: ;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM