Jump to content
  • Advertisement


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


Doodle Program

This topic is 5648 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is the code for my doodle program. Ideally, I want the program to output an astericks when you press the designated keys, I,J,K, and L, and I want a beeping sound when you do not press one of those keys. I thought my code would fullfill these requirements, but it outputs the letters I press and not an astericks, and it beeps even if I press the correct letters. Someone please help me!!!!
/*This is the Doodle Program. It is a programmed designed to allow the user
to draw images using asterisks marks. Brendan Harnett 4/2/03
(C) Brendan Harnett All Rights Reserved */

#include <iostream.h>
#include <conio.h>//Needed to use the Borland specific functions
#include <time.h>//Needed to use the computer's clock
#include <stdlib.h>
int main()
 int srand(time(0));
cout<<"Doodler! Press I/J/K/L to move, Q to quit"<
Oh, and by the way, I have a Dev C++ compiler, I don't know if that has anything to do with it, but I think that it could possibly help people give me advice.
[edited by - bioagentX on April 2, 2003 5:12:18 PM]

Share this post

Link to post
Share on other sites
Well, I''m not the C(++) expert around here, but you might wanna replace those "else if" statements with a case statement.

Share this post

Link to post
Share on other sites
I'm not sure about C++ either, but I know your problem is in cin.get(). The input buffer is flushed only when it encounters a newline, so if you type "i 'Enter'" it sends the i and the 'Enter' (I think). Regardless, if you replace the cin.get() with getch() you're program works dandy. I also placed an "endl" at the end of each cout line, for similar flush-related reasons. Don't know if it's necessary, but it worked. Who needs C++ anyway. C++-- for life!

[edited by - fisheyel83l on April 3, 2003 3:42:37 AM]

Share this post

Link to post
Share on other sites
If you just want a flush, and not a newline also, then you can use flush instead of endl... At least, I think it is flush...

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!