Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,376 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,155 people online right now. Registration is fast and FREE... Join Now!




Syntax error

 
Reply to this topicStart new topic

Syntax error, error C2059: syntax error : 'return'

dinci5
post 25 Oct, 2006 - 06:58 AM
Post #1


New D.I.C Head

*
Joined: 19 Oct, 2006
Posts: 33


My Contributions


Hellow
I made the Paper-rock-scissor game in C++
And when trying to compile, I get the following error:
error C2059: syntax error : 'return'

here is my code, I don't see what I did wrong


btw, language is Dutch, so don't be surprised tongue.gif

CODE
#include <iostream>
using namespace std;

int main()
{

    char keuze, keuze1, keuze2;
    bool tryAgain = true;

    while ( tryAgain == true ) //zolang tryAgain true blijft wordt de lus herhaald
    {
        cout << "Schaar : S of s\n Steen = R od r\n Papier = P of p\n ";

        cout << " Speler 1 : Schaar, Steen of Papier?\n ";
        cin >> keuze1;
        cout << " Speler 2 : Schaar, Steen of Papier?\n ";
        cin >> keuze2;

    do
    {
        switch (keuze1)
        {
        case 'P':
        case 'p':
        if (keuze2 == 'P' || keuze2 == 'p')
            cout << " Niemand wint ";
        else if
            (keuze2 == 'R' || keuze2 == 'r')
            cout << " Speler 1 wint! Het blad pakt de steen in!";
        else
            cout << " Speler 2 wint! De schaar knipt papier!";
        break;

        case 'R':
        case 'r':
        if (keuze2 == 'R' || keuze2 == 'r')
            cout << " Niemand wint ";
        else if
            (keuze2 == 'S' || keuze2 == 's')
            cout << " Speler 1 wint! De steen maakt de schaar bot!";
        else
            cout << " Speler 2 wint! Het blad pakt de steen in!";
        break;

        case 'S':
        case 's':
        if (keuze2 == 'S'|| keuze2 == 's')
            cout << " Niemand wint!";
        else if
            (keuze2 == 'P' || keuze2 == 'p')
            cout << " Speler 1 wint! De schaar knipt papier!";
        else
            cout << " Speler 2 wint! De steen maakt de schaar bot!";
        break;

        default:
            cout << "U hebt een verkeerde keuze gemaakt!";
        }
        cout << "Nog een keer? <j/n> : \n";
        cin >> keuze;
          
        if ( keuze == 'n' || keuze == 'N' ) //Als je nee (n of N) kiest, dan wordtt tryAgain false en de lus wordtt onderbroken
        {
            tryAgain = false;
        }
    }
        return 0;
    }

}
User is offlineProfile CardPM

Go to the top of the page

Antiokus
post 25 Oct, 2006 - 07:11 AM
Post #2


D.I.C Head

**
Joined: 6 Sep, 2006
Posts: 125



Thanked 1 times
My Contributions


I just went through your code, and it looks like you have Do While loop that has no while. Although you alread placed all the code inside of a seperate while loop, so you can just delete the 'Do{ }' out of your code and move the return 0; to outside of the while loop.

CODE
   }
    return 0;
   }
}

should be:
CODE
   }
   }
return 0;
}
User is offlineProfile CardPM

Go to the top of the page

dinci5
post 25 Oct, 2006 - 07:43 AM
Post #3


New D.I.C Head

*
Joined: 19 Oct, 2006
Posts: 33


My Contributions


yeah you're right
I first did it with a do while loop
but then I made it with only the while loop and the boolean (tryAgain) ... it is easyer like that


thx for the quick help smile.gif
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/22/08 06:11AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month