Jump to content

  • Log In with Google      Sign In   
  • Create Account

Parse Error?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
26 replies to this topic

#21 IRDumb   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 October 2001 - 09:49 AM

Never mind, got it. Thanks anyways.

Sponsor:

#22 Oluseyi   Staff Emeritus   -  Reputation: 1678

Like
Likes
Like

Posted 10 October 2001 - 09:55 AM

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.

#23 IRDumb   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 October 2001 - 11:03 AM

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?

#24 Oluseyi   Staff Emeritus   -  Reputation: 1678

Like
Likes
Like

Posted 10 October 2001 - 01:55 PM

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;
}


#25 IRDumb   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 October 2001 - 03:10 PM

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?

#26 Oluseyi   Staff Emeritus   -  Reputation: 1678

Like
Likes
Like

Posted 10 October 2001 - 07:00 PM

quote:
Original post by IRDumb
I was wondering, can i add sound to a dos program?


Yes.

quote:
And if so, how?


That's a slightly more complicated question. You could add simple beeps by printing the alarm escape character (cout << "\a"; ) You could pull up the old assembler and program the speaker device (aaaaaaaaaaaaaaaaaaaaaaaaargh!)

You could learn to program the SoundBlaster, the Gravis Ultrasound and Ad Lib-compliant sound cards (aaargh! Short scream.) There are libraries that can help you do all this, though, so it's no longer as painful as it used to be.

Or... you could switch to Windows, learn to program DirectSound and kick your feet up after that. Your choice. note, however, that sound is not an introductory topic; you need a firm grasp of programming to do even simple sound programming.

EDIT: misinterpreted smiley.

Edited by - Oluseyi on October 11, 2001 10:43:55 PM

#27 catfoodgood   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 October 2001 - 09:39 AM

This is the best thread I have seen in this room since I started visiting this forum a few months ago. I think it is really nice when people post actual questions instead of just saying "How do I make a game?" and then getting angry with the people who reply for telling tham that they need to study and learn programming. It is obvious that IRDumb is taking the time to learn how to code instead of trying to find the "magic" program or advice that is going to make a game for him (or her.) Anyway my point is that I am a beginner too, and it makes me happy to see the experienced programmers are willing to help out us students, and to the instant gratification people looking for the magic program and the shortcut my advice is try another job, because the one constant in this forum is that there is no shortcut.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS