ok guys heres the problem (by the way i am a beginner programmer so don't laugh at the code lol) i keep getting this declaration syntax error whenever i try to compile this program (i also get a declarations missing; and compound statement missing} ) but everything in my code apears alright to me. so here is the code i got so far, maybe you guys can fix it.

#pragma hdrstop
#include <condefs.h>
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>

//---------------------------------------------------------------------------
#pragma argsused
void attack (int & hp, int dammage, int def, int & chp, int cdammage, char *name, int & gp, int cgp, int & nextlevel, int & exp, int cxp);
void usepotion (int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & hp, char *name, int maxhp);
void battle (int & hp, int & gp, int & exp, int & agilitylvl, int &  lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int dammage, int def, int chp, int cgp, int cdammage, int cexp,char *name, int & nextlevel, int & maxhp, char *nextweapon, int & blocked, int & level);
int main(int argc, char **argv)
{
// charecter stuff
int maxhp;
int hp;
int gp=120;
int exp=0;
int nextlevel=80;
int level=1;
int agilitylvl=0;
int def=0;
int dammage;
// items
int lvl1potions=0;
int lvl2potions=0;
int lvl3potions=0;
int demonpotions=0;
int secretitems=0;
// misc
int score=0;
int charecter;
int hplost;
int gameplaychoice;
int choice;
int blocked;

    cout << "A role playing game by Nate Nelson" << endl << endl;
    cout << "choose your character" << endl;
    cout << "1: Barbarian" << endl;
    cout << "2: Wizard of The Old Teachings" << endl;
    cout << "3: Gnome" << endl << endl;
    cin >> charecter;
        if (charecter == 1){
            cout << "You have chosen the nobelist and fiercest warrior in all the land, Abdazar!" << endl;
            cout << "the time has now come to choose you mode of battle." << endl << endl;
            cout << "Press any key to continue..." << endl << endl;
            getch();
            cout << "1: I would like to fight with a Giant Axe." << endl;
            cout << "2: I would like to fight with a Sword and Shield." << endl;
            cin >> choice;
                if (choice == 1){
                    hp = 50;
                    maxhp = 50;
                    def = 2;
                    cout << "Your weapon shall be an Axe like tree root." << endl << endl;
                    cout << "As your adventure begins you decide to randomly choose a direction" << endl;
                        cout << "You have stumbled upon a Goblin Warrior, he has spoted you and" << endl;
                        cout << "wishes to fight!" << endl;
                        cout << "You Valiantly fight the monster for your life." << endl << endl;
                        //this is where battle sounds or music is played
                        dammage = 10;
                        int goblinhp = 20;
                        int goblinexp = 20;
                        int goblingp = 20;
                        hplost = hp;
                        goblinhp = goblinhp-10;
                        hp = hp-5+2;
                        goblinhp = goblinhp-10;
                        hp = hp-5+2;
                        hplost = hplost-hp;
                        gp = gp+goblingp;
                        hp = hp+5;
                        exp = exp + goblinexp;
                        cout << "you have fought valiently and killed the beast!" << endl;
                        cout << "your Hit points are now at " << hp << "." << endl;
                        cout << "you lost " << hplost << " hit points, but gain " << "5" << " life back from a potion the goblin had." << endl;
                        cout << "you have gained " << exp << "/" << nextlevel << " till your next level." << endl;
                        cout << "you have gained " << goblingp << " GP from the goblin.  Your GP is at " << gp << "." << endl << endl;
                        getch();
                        cout << "What would you like to do now then?" << endl << endl;
                        cout << "1: Wander aimlessly some more (fight)." << endl;
                        cout << "2: Go East to Falador." << endl << endl;
                        cin >> gameplaychoice;
                            if (gameplaychoice == 1){
                                //2nd attack
                                cout << "As you wander aimlessly around a goblin spots you and attacks!" << endl << endl;
                                battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, 20, 20, 5, 20, "goblin", nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 0, level);
                                cout << "What would you like to do now then?" << endl << endl;
                                cout << "1: Wander aimlessly some more (fight)." << endl;
                                cout << "2: Go East to Falador." << endl << endl;
                                cin >> gameplaychoice;
                            }
                                if (gameplaychoice == 1){
                                    //3rd attack
                                    cout << "As you wander aimlessly around a goblin spots you and attacks!" << endl << endl;
                                    battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, 20, 20, 5, 20, "goblin", nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 0, level);
                                    cout << "What would you like to do now then?" << endl << endl;
                                    cout << "1: Wander aimlessly some more (fight)." << endl;
                                    cout << "2: Go East to Falador." << endl << endl;
                                    cin >> gameplaychoice;
                                }
                                    if (gameplaychoice == 1){
                                        //4th attack
                                        cout << "As you wander aimlessly around a goblin spots you and attacks!" << endl << endl;
                                        battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, 20, 20, 5, 20, "goblin", nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 0, level);
                                        cout << "What would you like to do now then?" << endl << endl;
                                        cout << "1: Wander aimlessly some more (fight)." << endl;
                                        cout << "2: Go East to Falador." << endl << endl;
                                        cin >> gameplaychoice;
                                    }
                            else if (gameplaychoice >= 2) {
                                cout << "Goblin Warlord: I hear you have been harrassing my goblin troops!" << endl << endl;
                                cout << "Abdazar: yeah i have been training with your troops, but i haven't been Harrassing them!" << endl << endl;
                                cout << "Goblin Warlord: That's not the way I heard it, prepare yourself for revenge!" << endl << endl;
                                cout << "Abdazar: Alright if it is a battle you want, a battle you shall have." << endl << endl;
                                battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, 200, 200, 14, 200, "goblin", nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 0, level);

                            }
                }
getch ();

        }
        return 0;
}
void battle (int & hp, int & gp, int & exp, int & agilitylvl, int &  lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int dammage, int def, int chp, int cgp, int cdammage, int cexp,char *name, int & nextlevel, int & maxhp, char *nextweapon, int & blocked, int & level)
{
int choice;
int blockyesno;
int attackedxtimes=0;
cout << "what should i do?" << endl << endl;
cout << "1: Attack" << endl;
cout << "2: Use potion" << endl;
cout << "3: Attempt to block" << endl;
cin >> choice;
    if (choice == 1){
        attackedxtimes++;
        if (attackedxtimes  != (2 || 5)){
            if (attackedxtimes != (3 || 6)){
                if (chp && hp > 0){
                    battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 0, level);
                }
            }

        }
        else if (attackedxtimes == (2 || 5)) {
                if (chp && hp > 0){
                    battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 0, level);
                }
            cout << name << " apears to be getting ready for some sort of special attack." << endl << endl;
        }
        else if (attackedxtimes == (3 || 6)) {
                if (chp && hp > 0){
                    battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 0, level);
                }

    }
    else if (choice == 2){

        usepotion (lvl1potions, lvl2potions, lvl3potions, demonpotions, hp, name, maxhp);
        if (chp && hp > 0){
        battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 0, level);
        }
    }
    else if (choice == 3){
        blockyesno = rand() % 100 + 1;
        blocked++;
            if (blockyesno <= (agilitylvl*10)){
                cout << "all dammage was successfully blocked this turn!" << endl << endl;
                cout << "Abdazar" << "              " << name << endl;
                cout << hp << "                      " << chp << endl << endl;
                battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 0, level);
                getch();
            }
            else if (blockyesno >= ((agilitylvl*10)+1)){
                cout << "you accedentally take a wrong step as you attempt to block and still take" << endl <<" dammage."<< endl << endl;
                hp = hp - cdammage;
                cout << "Abdazar" << "              " << name << endl;
                cout << hp << "                      " << chp << endl << endl;
                getch();
                battle (hp, gp, exp, agilitylvl, lvl1potions, lvl2potions, lvl3potions, demonpotions, dammage, def, chp, cgp, cdammage, cexp, name, nextlevel, maxhp, "large stick with a sharp rock tied to the end of it", 0, level);
            }

    }
    if (exp == nextlevel) {
        cout << "you have gained enough expierience to level up!!!" << endl << endl;
        maxhp = maxhp * 1.5;
        def = def + 3;
        hp = maxhp;
        agilitylvl++;
        dammage = dammage+5;
        cout << "your max hp is now " << maxhp << endl;
        cout << "your defense is now " << def << endl;
        cout << "your agility level is now " << agilitylvl << endl;
        cout << "you find a new weapon on " << name << ". you decide to use this instead of your old weapon." << endl;
        cout << "your weapon shall now be a " << nextweapon << endl << endl;
        level++;
    }





}

void usepotion (int & lvl1potions, int & lvl2potions, int & lvl3potions, int & demonpotions, int & hp, char *name, int maxhp)
{ //it says the declaration syntax error is here 
int potionchoice;
    if (lvl1potions == 0) {
        if (lvl2potions == 0){
            if (lvl3potions ==0){
                if (demonpotions == 0){
                    cout << "you have no potions, quick pick a battle move before " << name << " attacks you!" << endl;
                    return ;
                }
            }
        }
    }
cout << "Use which potion?" << endl << endl;
    if (lvl1potions >= 1) {
        cout << "1: level 1 potion" << endl;
    }
    if (lvl2potions >= 1){
        cout << "2: level 2 potion" << endl;
    }
    if (lvl3potions >= 1) {
        cout << "3: level 3 potion" << endl;
    }
    if (demonpotions >= 1) {
        cout << "4: Demonic potion" << endl;
    }
cin >> potionchoice;
    if (potionchoice == 1) {
        lvl1potions = lvl1potions-1;
        hp = hp + 20;
        cout << "you have gained 20 hp, your hp is now at " << hp << endl << endl;
            if (hp > maxhp ){
                hp = maxhp;
            }
    }
    else if (potionchoice == 2) {
        lvl2potions = lvl2potions - 1;
        hp = hp + 30;
        cout << "you have gained 30 hp, your hp is now at " << hp << endl << endl;
            if (hp > maxhp ){
                hp = maxhp;
            }
    }
    else if (potionchoice == 3) {
        lvl3potions = lvl3potions - 1;
        hp = hp + 40;
        cout << "you have gained 40 hp, your hp is now at " << hp << endl << endl;
            if (hp > maxhp ){
                hp = maxhp;
            }
    }
    else if (potionchoice == 4) {
        demonpotions = demonpotions - 1;
        hp = hp + 120;
        cout << "you have gained 120 hp, you hp is now at " << hp << endl << endl;
            if (hp > maxhp ){
                hp = maxhp;
            }
    }

}

void attack (int & hp, int dammage, int def, int & chp, int cdammage, char *name, int & gp, int cgp, int & nextlevel, int & exp, int cxp)
{
int hplost;
hplost = hp + def;
chp = chp - dammage;
int won;
    if (chp <= 0 ) {
        won = 1;
        cout << "You are victorious!!!" << endl << endl;
        exp = exp + 20;
        hplost = hplost - hp;
        hp = hp + cdammage;
        gp = gp + cgp;
        cout << "you lost " << hplost << " hit points, but gain " << cdammage << " life back from a potion the " << name << " had." << endl;
        cout << "your Hit points are now at " << hp << "." << endl;
        cout << "you have gained " << exp << "/" << nextlevel << " till your next level." << endl;
        cout << "you have gained " << cgp << " GP from the " << name << ".  Your GP is at " << gp << "." << endl << endl;
    }
hp = hp - cdammage;
    if (hp <= 0 ) {
        exp = exp + cxp;
        hplost = hplost - hp;
        cout << "you lost " << hplost << " hit points, but gain " << cdammage << " life back from a potion the " << name << " had." << endl;
        cout << "your Hit points are now at " << hp << "." << endl;
        cout << "you have gained " << exp << "/" << nextlevel << " till your next level." << endl;
        cout << "you have gained " << cgp << " GP from the goblin.  Your GP is at " << gp << "." << endl << endl;

        getch();
    }
    if (won == 1) {
        hp = hp + cdammage;
    }
cout << "Abdazar" << "              " << name << endl;
cout << hp << "                      " << chp << endl << endl;

}
// points both missing statements (; and } ) to after the program (empty lines).

thought i would add that i run in windows, and use a program called Borland C++ Builder 3. (dunno if this will help you see the problem any better.)

Poor indentation strikes again!

The function battle() appears to be missing a closing }.

lol ty for headsup lol.

lol ok here is the next confusing part then. I closed battle() right above usepotion() (it is the only then that can close at that indentation aswell, but if i put a second } directly below it, the program runs. (can anyone explain this then?)

This it pretty nasty looking code to debug; it looks like stuff I wrote when I was 10.

if ( attackedxtimes  != (2 || 5) )

You'd better take another look at your C or C++ reference.

And search for blocked. You have scope issues -- I advise renaming one of them: the parameter or the temporary.

This it pretty nasty looking code to debug; it looks like stuff I wrote when I was 10.

if ( attackedxtimes  != (2 || 5) )

You'd better take another look at your C or C++ reference.

And search for blocked. You have scope issues -- I advise renaming one of them: the parameter or the temporary.

yeah i changed that line (and found what i didn't close)
it is now

if (attackedxtimes  != 2 &&attackedxtimes != 5){

lol just a couple of things, first of all keep in mind that i started c++ about 2 weeks ago monday so i am an extreme noob lol. so i am writing a basic program for a role playing game lol.

second, what do you mean by either the temporary or the paramater for blocked. i am gonna use blocked later on, i need to know how many times they blocked (it is for a secret item later on if you successfully block a boss 3 times you get it) (i also moved blocked++; to where he successfully blocks not just if he tries.)

lol just a couple of things, first of all keep in mind that i started c++ about 2 weeks ago monday so i am an extreme noob lol. so i am writing a basic program for a role playing game lol.

No -- no offense meant. The "just started"-ness is all I implied.

second, what do you mean by either the temporary or the paramater for blocked. i am gonna use blocked later on, i need to know how many times they blocked (it is for a secret item later on if you successfully block a boss 3 times you get it) (i also moved blocked++; to where he successfully blocks not just if he tries.)

I was just looking my compiler output:

Warning W8030 testpp.cpp 91: Temporary used for parameter 'blocked' in call to 'battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)' in function main(int,char * *)
Warning W8030 testpp.cpp 101: Temporary used for parameter 'blocked' in call to 'battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)' in function main(int,char * *)
Warning W8030 testpp.cpp 111: Temporary used for parameter 'blocked' in call to 'battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)' in function main(int,char * *)
Warning W8030 testpp.cpp 123: Temporary used for parameter 'blocked' in call to 'battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)' in function main(int,char * *)
Warning W8080 testpp.cpp 131: 'blocked' is declared but never used in function main(int,char * *)
Warning W8004 testpp.cpp 131: 'score' is assigned a value that is never used in function main(int,char * *)
Warning W8004 testpp.cpp 131: 'secretitems' is assigned a value that is never used in function main(int,char * *)
Warning W8004 testpp.cpp 71: 'goblinhp' is assigned a value that is never used in function main(int,char * *)
Warning W8004 testpp.cpp 22: 'def' is assigned a value that is never used in function main(int,char * *)
Warning W8030 testpp.cpp 151: Temporary used for parameter 'blocked' in call to 'battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)' in function battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)
Warning W8030 testpp.cpp 160: Temporary used for parameter 'blocked' in call to 'battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)' in function battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)
Warning W8030 testpp.cpp 168: Temporary used for parameter 'blocked' in call to 'battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)' in function battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)
Warning W8030 testpp.cpp 178: Temporary used for parameter 'blocked' in call to 'battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)' in function battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)
Warning W8030 testpp.cpp 190: Temporary used for parameter 'blocked' in call to 'battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)' in function battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)
Warning W8004 testpp.cpp 211: 'dammage' is assigned a value that is never used in function battle(int &,int &,int &,int &,int &,int &,int &,int &,int,int,int,int,int,int,char *,int &,int &,char *,int &,int &)

You are passing 0, but pass-by-reference expects a variable (I believe).

If you want pass-by-value, say so in the function declaration and definition.

lol i was wondering about those wanings i got too, but it ran without it, so i didn't think much of it. i can use the variable and set it equal to 0 first, that oughta work.

#include <iostream>
#include <string>
using namespace std;

string GetName()
{
string FirstName, LastName, FN;

cout << "Employee's First Name: ";
cin >> FirstName;
cout << "Employee's Last Name: ";
cin >> LastName;

FN = FirstName + " " + LastName;

return FN;
}

int main()
{
string FullName;
double Hours;

double GetHours(string FullName);

FullName = GetName();

Hours = GetHours(FullName);

cout << "\nEmployee's Name: " << FullName;
cout << "\nWeekly Hours: " << Hours << " hours\n\n";

return 0;
}

double GetHours(string FullName)
{
double Mon, Tue, Wed, Thu, Fri, TotalHours;

cout << endl << FullName << "'s Weekly Hours\n";
cout << "Monday: ";
cin >> Mon;
cout << "Tuesday: ";
cin >> Tue;
cout << "Wednesday: ";
cin >> Wed;
cout << "Thursday: ";
cin >> Thu;
cout << "Friday: ";
cin >> Fri;

TotalHours = Mon + Tue + Wed + Thu + Fri;

return TotalHours;
}

This article has been dead for over six months. Start a new discussion instead.