• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

IRDumb

Parse Error?

26 posts in this topic

Whenever I try and compile my code on dev-cpp, I get all these parse error, like on my bracket ({) or something. It says something like this... parse error before ''<'' parse error before ''['' and so on... What is going on?
0

Share this post


Link to post
Share on other sites
You haven''t given enough information for anybody to help you specifically. The only advice I can give is to start at the top of your error list, not the bottom.
0

Share this post


Link to post
Share on other sites
Ok, well try this...

(I just did this right now in my compiler, dev)

#include
void main()
{
int age
cout<<"hello world\n";
cout<<"how old are you?\n";
cin>>age;
cout<<"you are"<}

The only error I got was "parse error before `<''" in line 5.
Also, when I said, "execute" nothing happened, even though the
box was saying execute.

0

Share this post


Link to post
Share on other sites
You need to put a semi-colon ";" after int age...

Also, use the tags [ source ] and [ /source ] (without the extra spaces) around any code you post so it doesn''t think the less than/greater than signs are HTML.

Anthracks
0

Share this post


Link to post
Share on other sites
Hmm, you should read the FAQ. It explains how to post code without having things get eaten by HTML by using certain special tags. I forget what they are at the moment.

As far as the code you posted, it looks like you''re missing a ; on line 4 after "int age". With C/C++, when the compiler gives an error on a specific line, the problem isn;t necessarily on that line. Often incorrect code on previous lines can''t be detected and reported by the compiler until it reachs a point on a later line.
0

Share this post


Link to post
Share on other sites
Ok, thanks
After the semicolon it was fine, so I guess I just miss semicolons and stuff. And I''ll do that
    
next time too.
Now another thing-
*Why does''t the program execute even after I compile it no errors? What happens is I click execute, and the top blue status/tool bar thing goes from blue to gray and then returns?
0

Share this post


Link to post
Share on other sites
either include stdlib.h and use system("PAUSE") at the end of the program, or include stdio and use getchar()

0

Share this post


Link to post
Share on other sites
oh, and also,
cin >> somefakevariable works pretty well, for example

char somefakevariable;
cin >> somefakevariable;

:D

0

Share this post


Link to post
Share on other sites
Ok, now I have a new error.
When I try this...
  if(pick1==2)
{
cout<<"You''re right!\n";
x=x+1;
b();
}
else if(pick1!=2)
{
cout<<"Wrong. The correct answer was 2.\n";
b();
}
}


after a question in my trivia game, it compiles with zero errors but after I answer the question in the dos program, it always says wrong no matter what I typed in. Is it a problem with my if/else if statement?

Oh, FYI, "x" is the results thing and "pick1" is the choice they enter.
0

Share this post


Link to post
Share on other sites
Again, we need a little more information to help you, such as the type of pick1 (I''ll just assume it''s an int) and the scope of the if-elseif statement black. However, here''s a little tip: since "2" is the only correct answer, do:

if(pick1 == 2)
{
cout << "You''re right!\n";
// ++x, x++, x+= 1 and x = x+1 are similar.
// Since you don''t care whether it happens before
// or after this statment, use ++x;
++x;
b();
}
else
{
cout << "Sorry, the answer is 2.\n";
b();
}

The other thing is make sure your pick1 is an integer (int); if it''s a char then it wont behave the way you expect.
0

Share this post


Link to post
Share on other sites
I tried that and it still didn''t work. Here is the whole thing.
  #include <stdio.h>
#include <iostream.h>
void a();
void b();
void c();
void start();
void results();
int pick, x;

void a()
{
int pick1;
cout<<"How many bones are in the human body?\n";
cout<<"1. 100\n";
cout<<"2. 206\n";
cout<<"3. 266\n";
cout<<"4. Over 1000\n";
cin>>pick;
pick=pick1;
if(pick1==2)
{
cout<<"You''re right!\n";
++x;
b();
}
else
{
cout<<"Wrong. The correct answer was 2.\n";
b();
}
}
void b()
{
int pick2;
cout<<"What is the name of our currenet president?\n";
cout<<"1. Ronald Reagan\n";
cout<<"2. John Kennedy\n";
cout<<"3. Bill Clinton\n";
cout<<"4. George Bush\n";
cin>>pick;
pick=pick2;
if(pick2==4)
{
cout<<"You''re right!\n";
++x;
c();
}
else
{
cout<<"Wrong. The correct answer was 4.\n";
c();
}
}
void c()
{
int pick3;
cout<<"What is 12x12?\n";
cout<<"1. 100\n";
cout<<"2. 122\n";
cout<<"3. 144\n";
cout<<"4. 1212\n";
cin>>pick;
pick=pick3;
if(pick3==3)
{
cout<<"You''re right!\n";
++x;
results();
}
else
{
cout<<"Wrong. The correct answer was 3.\n";
results();
}
}
void results()
{
cout<<"Your score was "<<x<<".\n";
start();
}
void start()
{
cout<<"Welcome. Here is your first question.\n";
a();
}

int main(int argc, char *argv[])
{
cout<<"Welcome to the trivia game.\n";
cout<<"To play, type in a number 1-4 in accordance with the question.\n";
start();
}
0

Share this post


Link to post
Share on other sites
I really am stupid.
All I had to do was take out int pick at the top and pick=pick 3 etc. and it worked fine! Thank you guys for all your help.
0

Share this post


Link to post
Share on other sites
Ok, here is what you have:

  
int pick1;
cout<<"How many bones are in the human body?\n";
cout<<"1. 100\n";
cout<<"2. 206\n";
cout<<"3. 266\n";
cout<<"4. Over 1000\n";
cin>>pick;
pick=pick1;
if(pick1==2)
{
cout<<"You''re right!\n";
++x;
b();
}
else
{
cout<<"Wrong. The correct answer was 2.\n";
b();
}


Look at these two lines in particular:
  
cin>>pick;
pick=pick1;

it should be:
  
pick1=pick;

otherwise you overwrite the value you read in with the uninitialized value that was in pick1 when the routine was put on the stack.

Remeber your assignment ordering. The variable to left of the operator receives the value from the variable to the right of the operator.

RandomTask
0

Share this post


Link to post
Share on other sites
Ok, I promise, this is the last parse error. I added a lot to the program and I can get it down to one error:
Parse error at end of input

I didn''t change int main() at all so why is it saying parse error at end of input?
I would post the new thing up there but it is really long(like 175 lines) so if you can help, thanks.
My e-mail is "Rick__33@hotmail.com" if you want to see it.
0

Share this post


Link to post
Share on other sites
Another thing I find interesting is that you''re chaining your functions, which is bad (it uses up stack space, but for now just know that it''s bad.) Here''s a new main() for you:

bool not_done = true;

// don''t worry about argc and argv
int main(int argc, char *argv[])
{
while(not_done)
{

cout<< "Welcome to the trivia game.\n";
cout<< "To play, type in a number 1-4 in accordance with the question.\n";
start();
a();
b();
c();
result();
// add some code to ask the use if he want to quit or play again
}
}

Remove the calls to the other functions inside your current functions (ie, don''t have a() call b() and so forth.) You can''t escape the while loop because the way you currently link your functions will eventually blow your stack (you''ll run out of memory for your program.)

Now as for the parse error, check all your punctuations - semicolons at the end of every line, etc.
0

Share this post


Link to post
Share on other sites
Ok, I''ll change the format later tonight.
One thing I don''t really understand is what bool means. How is it used in code?
0

Share this post


Link to post
Share on other sites
bool means Boolean (named after the mathematician George Boole - at least I think it was George...), and are variables that evaluate to "true" or "false." Until bool became a part of the C++ language, programmers usually defined their own custom boolean type (which was either an entire integer or a bit in a bitfield); the Win32 API even has BOOL defined!

All you need to know is that a variable of type bool can either be true or false (and you assign "true" or "false" to them like in my example), which means you can use them in branching:

if(boolean_condition)
{
do_something;
}
else
{
do_something_else;
}
0

Share this post


Link to post
Share on other sites
Ok, I kind of knew that.
I re-did my program and it works just as good. (8 questions now!)
I was wondering, can i add sound to a dos program? And if so, how?
0

Share this post


Link to post
Share on other sites