Help!

I have syntax error here:

// wew.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream"
#include "conio.h"

using namespace std;

int choice;
char decide;

int mainMenu();

int choices(int choice)
{
switch(choice)
{
case 1:
system("cls");
cout << "Description" << endl << endl;
cout << endl << endl << "Go back to Main Menu (y/n)?"<< endl;
cin >> decide;
if(decide == 'y')
{
mainMenu();
}
break;

case 2:
do
{
system("cls");
cout << "Description" << endl << endl << endl;
cout << endl << endl << "Go back to Main Menu (y/n)?"<< endl;
cin >> decide;
if(decide == 'y')
{

mainMenu();
}


}

return 0;
break;
}
return 0;
}

int mainMenu()
{
system("CLS");
cout << "Main menu" << endl << endl;
cout << "[1]Choice1" << endl;
cout << "[2]Choice2" << endl;
cout << "[3]Choice3" << endl;
cout << endl << "Enter your choice: ";
cin >> choice;
choices(choice);

getch ();
return 0;
}

int main()
{
mainMenu();
}





It says that cpp(46): error C2059: syntax error : 'return'

What should i do and whats wrong in my program?
Last edited on
You should make sure you put a while in your do-while loop.
I removed the do-while loop then i got errors
here is my program now:

// wew.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "iostream"
#include "conio.h"

using namespace std;

int choice;
char decide;

int mainMenu();

int choices(int choice)
{
switch(choice)
{
case 1:
system("cls");
cout << "Description" << endl << endl;
cout << endl << endl << "Go back to Main Menu (y/n)?"<< endl;
cin >> decide;
if(decide == 'y')
{
mainMenu();
}
break;

case 2:

{
system("cls");
cout << "Description" << endl << endl << endl;
cout << endl << endl << "Go back to Main Menu (y/n)?"<< endl;
cin >> decide;
if(decide == 'y')
{

mainMenu();
}
break;
}


case 3:
{
exit(3);
default: "invalid choice";
break;

}
}

int mainMenu();
{
system("CLS");
cout << "Main menu" << endl << endl;
cout << "[1]Choice1" << endl;
cout << "[2]Choice2" << endl;
cout << "[3]Choice3" << endl;
cout << endl << "Enter your choice: ";
cin >> choice;
choices(choice);

_getch ();
return 0;
}

int main()
{
mainMenu();
}


then the errors:

cpp(71): error C2601: 'main' : local function definitions are illegal
cpp(16): this line contains a '{' which has not yet been matched

fatal error C1075: end of file found before the left brace '{' at 'c:\users\chris atienza\documents\visual studio 2010\projects\1\1\1.cpp(16)' was matched
You're missing braces.

If you format your code sensibly with indentations, you'd see that immediately.
cpp(56): error C2447: '{' : missing function header (old-style formal list?)
How to solve this?
Remove the semi-colon at the end of the start of the function definition.
What is system() doing in your code?????
Use notepad++ very good
Topic archived. No new replies allowed.