Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Need help with Collatz Conjecture Loop

Author
Message
ChristMatt
12
Years of Service
User Offline
Joined: 2nd Apr 2012
Location:
Posted: 2nd Apr 2012 20:07
My friend and I are writing a simple program that lets the user enter a number and the program runs a collatz conjecture on that number and shows each step. For whatever reason, it continues to crash/not run. We don't know if it's the schools crap computers or if there is a problem with our loop/functions. Any input is nice.

DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 3rd Apr 2012 09:04 Edited at: 3rd Apr 2012 09:13
Hmm, well I would usually put "void" in the argument for endprogram when I am defining and declaring it.

What?! Oh, well that might mean something. atoi takes a str but dbInput is VOID!

OK, so you should have something like this:


Note that dbInput passes int num by reference, so it will be altered by the function.

Have a look at the documentation on your computer if you haven't already. (C:\Program Files (x86)\The Game Creators\Dark GDK\Documentation).


ChristMatt
12
Years of Service
User Offline
Joined: 2nd Apr 2012
Location:
Posted: 3rd Apr 2012 20:05
Quote: "
Hmm, well I would usually put "void" in the argument for endprogram when I am defining and declaring it.

What?! Oh, well that might mean something. atoi takes a str but dbInput is VOID!

OK, so you should have something like this:+ Code Snippet
int num;
dbPrint("This program takes an imputted number from the user");
dbPrint("and tests it using Collatz Conjecture.");
dbPrint("");
dbPrint("");
dbInput("Please enter a number.",num);
dbPrint("");
dbPrint("Press any key to initialize test.");
dbWaitKey();

Note that dbInput passes int num by reference, so it will be altered by the function.

Have a look at the documentation on your computer if you haven't already. (C:\Program Files (x86)\The Game Creators\Dark GDK\Documentation).

"


We tried this but are getting errors now from the dbInput because it doesn't take 2 arguements.
matt yankello
12
Years of Service
User Offline
Joined: 3rd Apr 2012
Location:
Posted: 4th Apr 2012 00:48
Quote: "
Hmm, well I would usually put "void" in the argument for endprogram when I am defining and declaring it.

What?! Oh, well that might mean something. atoi takes a str but dbInput is VOID!

OK, so you should have something like this:+ Code Snippet

Note that dbInput passes int num by reference, so it will be altered by the function.

Have a look at the documentation on your computer if you haven't already. (C:\Program Files (x86)\The Game Creators\Dark GDK\Documentation).
"


Hi I am Christmatt's friend that he is talking about. I do not believe that this is the problem, for I tried running the program with the loop and it worked, well it gave the first number. This leads me to believe that the problem is how I set up the loop.
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 4th Apr 2012 01:47 Edited at: 4th Apr 2012 01:55
well, you could always fix num to see if you're loop works.
Then you'll know where the problem is.

The documentation says that dbInput takes 2 arguments. I've never used it though.
Quote: "Syntax
void dbInput ( char* szStatement, int iInput )
"


BTW, did you mean "without" here?
Quote: "for I tried running the program with the loop and it worked,"



One more thing. In general I don't use commands like atoi because I have had bad experiences with them. built in converters are usually built to crash the program if they receive an invalid input. Instead I make my own converter. I could explain how to do this, but it would kind of be a waste of my time if you don't care.

This isn't an issue though for your code since dbInput handles it.


WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 4th Apr 2012 02:08 Edited at: 4th Apr 2012 02:22
The problem is in the function itself. Try this, it works for me.



Cheers.
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 4th Apr 2012 02:17 Edited at: 4th Apr 2012 02:23
Quick question, why are you guys even using the Dark GDK?

Ok, so the guy above this post has code that works.

There is a disconnect between the documentation and the actual Dark GDK apparently when it comes to the dbInput command.


WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 4th Apr 2012 02:32 Edited at: 4th Apr 2012 02:34
Quote: "
There is a disconnect between the documentation and the actual Dark GDK apparently when it comes to the dbInput command.
"


So what's new? That's why I use IntelliSense.
ChristMatt
12
Years of Service
User Offline
Joined: 2nd Apr 2012
Location:
Posted: 4th Apr 2012 02:37
Quote: "Quick question, why are you guys even using the Dark GDK?"


We're taking a class that's being taught from the Gaddis book. We got bored, so we tried writing this program. When we hit a wall our teacher couldn't answer any of our questions, and so we came here instead. The end.
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 4th Apr 2012 03:11
Well, for the most part the documentation has been accurate as far as I've used it. So, I just learned about that command so its new for me.


matt yankello
12
Years of Service
User Offline
Joined: 3rd Apr 2012
Location:
Posted: 4th Apr 2012 03:54
Hi thanks for all the input but we actually fixed it by simply changing it to a do-while loop. I am not fully sure why this worked but it did. The reason why we are using darkgdk is because we are actually in high school and we took a c++ class only to learn that the school bought book for gaming and design IN c++ so darkgdk is all we know. And yes I did mean without. Not with
matt yankello
12
Years of Service
User Offline
Joined: 3rd Apr 2012
Location:
Posted: 4th Apr 2012 03:58
Wicked X thank you very much for your working code as well

Login to post a reply

Server time is: 2024-11-19 03:34:39
Your offset time is: 2024-11-19 03:34:39