codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Parse error that is slowly driving me insane  WSayin at 19:19 on Monday, March 07, 2005
 

Ok, that's the code I have in so far. There is only 1 error, On line 117, it says, "parse error before '*'"




112: void gameLoop()
113: {
114:
115: for(;;)
116: {
117: commands(char *com, char *obj);
118: }
119: }

I don't see whats wrong with it. I have typed it and retyped it over and over, changed the names, ex: comm(char *command, char *obj); and it still gives me that exact error. It seems that whenever I type in that one line, I have an error before the '*'... If I delete the stuff between the (), and just put a coma, it will then say, "parse error before ';'"

Please help me,
Will




#include <iostream.h>
//#include <conio_mingw.h>
#include <string.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <conio.c>

#define DRK_BLUE 1
#define DRK_GREEN 2
#define DRK_CYAN 3
#define DRK_RED 4
#define DRK_PURPLE 5
#define DRK_YELLOW 6
#define DRK_WHITE 7
#define GREY 8
#define BLUE 9
#define GREEN 10
#define CYAN 11
#define RED 12
#define PURPLE 13
#define YELLOW 14
#define WHITE 15


char msg(int color, char *str);

void start();
void stats();
void gameLoop();
int damage();
void commands(char *com, char *obj);
void move(char *dir);
void say(char *said);
struct player
{
char name[15];
int hp;
int max_hp;
int mana;
int max_age;
int age;
int x;
int y;
};
struct equip
{
int arm;
int leg;
int chest;
int head;
};
struct weapon
{
int minDam;
int maxDam;
};


player char_;
equip eq;
weapon weap;

int main()
{
start();
}

void start()
{
cout<<"Welcome to Will Sayin's Game"<<endl;
cout<<"By what name would you like to be known?";
cin>> char_.name;
int namelength;
namelength = strlen(char_.name); //certain length restrictions
if(namelength > 15)
{
cout<<"Name too long, try again."<<endl;
start();
}
if(namelength <3)
{
cout<<"Name too short, try again."<<endl;
start();
}

cout<<"Hello, "<<char_.name<<". How old are you?"<<endl;
cin>>char_.age;
stats(); //roll stats
}

void stats()
{
cout<<"Rolling base stats...\n\n"<<endl;
char_.hp = rand() %50 + 30;
char_.mana = rand() %100 +70;
cout<<char_.hp<<"hp ||"<<char_.mana<<" mana."<<endl;
msg(WHITE, "is this acceptable?y/n");
char yesno;
cin>>yesno;
if(yesno == 'Y'||yesno == 'y')
{
gameLoop();
}
else
{
msg(WHITE, "rerolling...");
stats();
}
}

void gameLoop()
{

for(;;)
{
commands(char *com, char *obj);
}
}


char msg(int color, char *str)
{
textcolor(color);
cout<<str<<endl;
textcolor(WHITE);
}


void commands(char *com, char *obj)
{
if(com == "go")
{
move(obj);
}
else if(com =="say")
{
say(obj);
}
else
{
msg(WHITE, "Invalid Command.");
gameLoop();
}
}

void move(char *dir)
{
if(dir == "north" || dir == "n")
{
char_.y--;
msg(YELLOW, "You move north.");
gameLoop();

}

else if(dir == "south" || dir == "s")
{
char_.y++;
msg(YELLOW, "You move south.");
gameLoop();
}

else if(dir == "east" || dir == "e")
{
char_.x++;
msg(YELLOW, "You move east.");
gameLoop();
}

else if(dir == "west" || dir == "w")
{
char_.x--;
msg(YELLOW, "You move west.");
gameLoop();
}

else
{
msg(RED, "No exit that direction.");
gameLoop();
}
}

void say(char *said)
{
cout<<"You say, '"<<said<<"'"<<endl;
}



  Re: Parse error that is slowly driving me insane  naveenkl at 13:46 on Friday, March 11, 2005
 

Hi,

I really do not know that what you are trying to do over there. The code can be something like this....


void gameLoop()
{
char com[256];//you can allocate statically or dynamically
char obj[256];

for(;;)
{
cout << endl << "Enter the command";
cin>> com;
cout << endl << "Enter the obj"
cin>> obj;
commands(com,obj);

}

}









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: C# and EXCEL question saving a file saving the the first column as read only
•  Iexplore -
•  Iframe and Div Layer Scrollbar Problem
•  Left margin increases as page fills.....
•  Re: Parse error that is slowly driving me insane
•  simple javascript/dhtml drop-down menu
•  notify an object that the user interface has changed one of its properties
•  Re: Print and print preview file on the website without using the File - Print on the IE
•  how we convert image into byte array in rmi


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005