![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Hobbyist Programmer
Join Date: Oct 2006
Posts: 146
Rep Power: 3
![]() |
primary expression, token } ????
**********DISCLAIMER*******************
I know that DaWei and others have told me to do my own research. I did, and learned a lot of what is in this program. But there are three errors that turned up irrelevant google search results, which no C++ error database had and which i simply do not understand. my books dont tell me about compiler errors either, so i am asking for your help **************************************** this is my 4th program, its for the chess team at my school when i compile this program /////////////////////////////
///////////////////////////////
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>
using namespace std;
int newratingsame(int ro, int s, int rop);
int newratingdiffr(int ro, int s, int rop);
int newratingdiffp(int ro, int s, int rop);
void initdisplay();
void secdisplay();
int main()
{
string b,c,d,e,f,g,h;
int a, ro, s, rop;
initdisplay();
cin >>a;
if (a == 1)
{
cout <<"Name of new player (no spaces):";
getline (cin,b);
c=b+"ratings.txt";
ofstream myfile3("namelist.txt");
myfile3 <<b <<"\n";
ofstream myfile2(c.c_str());
d="1200";
myfile2 <<d;
cout <<"Player added successfully, press enter to continue:";
system("PAUSE");
initdisplay();
}
if (a == 2)
{
int ab,pa,pb;
secdisplay();
cin >>ab;
if(ab==1)
{
string i,ia,is,ias;
int ans,ansa;
ifstream myfile4("namelist.txt");
while (! myfile4.eof() )
{
getline (myfile4,e);
cout << e << endl;
}
cout<<"Player 1's NAME:";
getline (cin, i);
i=i+"ratings.txt";
ifstream myfile7(i.c_str());
cout<<"Player 2's NAME:";
getline (cin, ia);
ia=ia+"ratings.txt";
ifstream myfile6(ia.c_str());
while (! myfile7.eof() )
{
getline (myfile7,is);
cout << is << endl;
}
while (! myfile6.eof() )
{
getline (myfile6,ias);
cout << ias << endl;
}
cout <<"\nenter P1 original rating (see above):";
cin >>pa;
cout <<"\nenter P2 rating (see above):";
cin >>pb;
//player 1
cout <<"did P1 win (1) lose(-1) or draw(0); enter correct number:";
cin >>s;
ans=newratingsame(pa,s,pb);
ofstream myfile8(i.c_str());
myfile8 <<ans;
//player2
cout <<"did P2 win (1) lose(-1) or draw(0); enter correct number:";
cin >>s;
ansa=newratingsame(pb,s,pa);
ofstream myfile9(ia.c_str());
myfile9 <<ansa;
cout <<"done";
system("PAUSE");
initdisplay();
}
if (a == 3)
{
ifstream myfile4("namelist.txt");
while (! myfile4.eof() )
{
getline (myfile4,e);
cout << e << endl;
}
cout << "Enter name of player whose rating you want to see:";
getline (cin,f);
g=f+"ratings.txt";
ifstream myfile5(g.c_str());
while (! myfile5.eof() )
{
getline (myfile5,h);
cout << h << endl;
}
initdisplay();
}
if (a ==4)
{system("PAUSE");}
system("PAUSE");
return 0;
}
void initdisplay()
{
cout << "////////////////////////////////////\n";
cout << "Chess Rating Manager v1.0\n";
cout << "Sreenath Pillai\n";
cout << "////////////////////////////////////\n\n\n\n";
cout << "[1] Add Player\n";
cout << "[2] Score Game\n";
cout << "[3] Check Ratings\n";
cout << "[4] Quit\n";
cout << "\n\nChoose:";
}
void secdisplay()
{
cout << "\n\n[1] both players rated OR both players provisional\n";
cout << "[2] one player rated and one player provisional\n";
cout << "[3] Back";
cout << "\n\nChoose:";
}
int newratingsame(int ro, int s, int rop)
{
return (ro + (s*21) + ((rop-ro)/25));
}
int newratingdiffr(int ro, int s, int rop)
{
return (ro + (s*6) + ((rop-ro)/100));
}
int newratingdiffp(int ro, int s, int rop)
{
return ((.8*ro) + (.2*rop) + (s*80);
}(everything in int main is fine) after int main, starting with the void initdisplay, i get errors that say the following: Quote:
im really frustrated the code should work of course i whipped this off in under an hour so there could easily be something i just missed ![]() idk, please help me!!! im sorry i really tried to solve it but i have no idea and i DID try research maybe some one could tell me a good place to research (not google, im not that dumb, i tried that, i tried wiki, MSDN help, devshed help, other forums, etc) i spent more time research than making the program! :mad: |
|
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
You're missing a brace to close "if (ab == 1)" in main. This propagates, which kicks the error to a point following main. Let me emphasize that you appear to be missing a brace. It's very hard to tell with the weird alignment. See if your editor has matching-brace capabilities; it helps a lot.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Oct 2006
Posts: 146
Rep Power: 3
![]() |
dawei, omg you are a friggin genius!
IT COMPILES AND LINKS!!!!!!!!!!!!!!!!!!! OMGOMGOMG AND IT RUNS! now i have to debug lol....some stuff works right but most of it doesnt thats ok though that i can do myself (for now at least) thanks so much DaWei, at that age you still have the keen eyes of a youngster ![]() |
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 894
Rep Power: 4
![]() |
You are missing a } after the call to initdisplay(); in the a==2 case.
The compiler is getting confused because it looks to it as if you are trying to define a function inside another function. Edit: well that what I get for not refreshing. |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Oct 2006
Posts: 146
Rep Power: 3
![]() |
i found a simpler way to make the program, takes up less than half the amount of code as well as 40% less file size BUT is just as effective and MOST IMPORTANTLY it works (whereas my other one doesnt LOL)
ill post it in the finished projects section |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| output - 842150451? | programmingnoob | C++ | 3 | Apr 23rd, 2006 9:23 PM |
| writing a scanner (lexical analysis) | programmingnoob | C++ | 6 | Mar 19th, 2006 5:12 PM |
| Pointers! Why? | LOI Kratong | C++ | 33 | Dec 18th, 2005 12:33 AM |
| BinaryTree , I need help on inserting expression to the Tree | Master | C# | 3 | Oct 14th, 2005 4:42 PM |
| Regular Expression HELP -- thanks | paulchwd | JavaScript and Client-Side Browser Scripting | 3 | Oct 11th, 2005 5:40 PM |