Syntax error

error C2059: syntax error : 'return'

Page 1 of 1

2 Replies - 1692 Views - Last Post: 25 October 2006 - 08:43 AM Rate Topic: -----

#1 dinci5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 19-October 06

Syntax error

Posted 25 October 2006 - 07:58 AM

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 :P

#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;
	}

} 


Is This A Good Question/Topic? 0
  • +

Replies To: Syntax error

#2 Antiokus  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 192
  • Joined: 06-September 06

Re: Syntax error

Posted 25 October 2006 - 08:11 AM

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.

   }
	return 0;
   }
}

should be:
   }
   }
return 0;
}

Was This Post Helpful? 0
  • +
  • -

#3 dinci5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 19-October 06

Re: Syntax error

Posted 25 October 2006 - 08:43 AM

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 :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1