mardi 27 septembre 2016

C++ Compile errors on lines that don't exsist. How to make restart function

When I compile this code I get I get Compilation errors: Errors below code.

#include <iostream>

using namespace std;
int main() 
{
    while (true) 
    {
        int go_again;
        go_again = 0;
        //[CODE HERE STARTS THREADS] Removed because it was unnecessary

        while (true) 
        {
            if ((GetAsyncKeyState(Settings()->exit_key)) // exits programm
            {
                go_again = 1;
                exit(0);
            }
            if ((GetAsyncKeyState(Settings()->restart)) // restarts programm
            {
                exit(0);
            }
            else
            {
                Sleep(100);
            }
        }
        if (go_again == 1)
        {
            exit(0);
        }
    }
    return 0;
}

Here are just some of the Errors:

main.cpp(323) : Empty Attribute block is not allowed.
main.cpp(323) : Syntax error: Missing ']' before /
main.cpp(323) : Empty Attribute block is not allowed.
main.cpp(468) : Sytax error: missing ']' before '/'.
main.cpp(468) : Sytax error: missing ';' before '/'.
main.cpp(468) : Sytax error: missing ';' before '{'.

EDIT: Another weird thing about the errors is its saying its on lines that don't exists, as there is only 100 lines of code, yet this says the errors are on line 468 etc. I am using custom version of visual c++ compiler.

There are alot more, but judging by the amount of errors, it seams that I have been doing the restart function wrong. Does anyone know the correct way to do a restart function and a stop function for the code? I am new to C++ so I am not that used to the syntax.

Aucun commentaire:

Enregistrer un commentaire