Mirage Source

Free ORPG making software.
It is currently Wed Apr 24, 2024 6:21 pm

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Teh Calc C++
PostPosted: Thu Apr 16, 2009 11:49 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
I made this a long long time ago...before I knew VB. I think I'll either pick C++ back up again or go with Java.

Attachment:
TehCalcTalk.rar [111.2 KiB]
Downloaded 370 times

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
 Post subject: Re: Teh Calc C++
PostPosted: Fri Apr 17, 2009 12:12 am 
Offline
Regular
User avatar

Joined: Tue May 30, 2006 5:52 am
Posts: 43
Very basic. It does what it needs to, though.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Teh Calc C++
PostPosted: Fri Apr 17, 2009 12:15 am 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
Lol @ bugs

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: Teh Calc C++
PostPosted: Fri Apr 17, 2009 12:28 am 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
The only bug I just now noticed was if you entered a letter as a response it would repeat over and over and over...

But yeah...fuck you Nean.

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
 Post subject: Re: Teh Calc C++
PostPosted: Fri Apr 17, 2009 12:58 am 
Offline
Persistant Poster
User avatar

Joined: Thu Jul 24, 2008 6:42 am
Posts: 703
Google Talk: infectiousbyte@gmail.com
GIAKEN wrote:
The only bug I just now noticed was if you entered a letter as a response it would repeat over and over and over...

But yeah...fuck you Nean.


That's what I noticed.

_________________
Image
GIAKEN wrote:
Since I'm into men, not women

GIAKEN wrote:
I can't take these huge penises anymore! All that's left is shame! And blood


Top
 Profile  
 
 Post subject: Re: Teh Calc C++
PostPosted: Fri May 15, 2009 5:34 am 
Offline
Regular
User avatar

Joined: Thu Aug 28, 2008 7:55 pm
Posts: 62
Quick fix

SPOILER: (click to show)
in your code replace
Code:
    if (e >= 6 | e <= -1)
    {
          while (e >= 6 or e <= -1)
          {
                cout << "The number you've entered isn't a proper choice, please choose 0 through 5." << endl;
                cin >> e;
          }
    }


with
Code:
   
if (e >= 6 | e <= -1)
    {
          while (e >= 6 or e <= -1)
          {
                cout << "The number you've entered isn't a proper choice, please choose 0 through 5." << endl;
                cin.clear(); //reset input flags
                cin.ignore(numeric_limits<streamsize>::max(),'\n') ;
                cin >> e;
          }
    }

Do this everywhere this problem happens.


Better fix
SPOILER: (click to show)
You could also (if you wish to create extra work) create a function that checks input for letters before returning a value
like so:
Code:
#include <cstdlib>
#include <iostream>
#include <limits>
 
using namespace std;

int intGet();
int main(int argc, char *argv[])
{
    int x = 0;
    while (x == 0)
    {
   
    x = intGet();
   
    }

    cout << endl << "Number:" << x << endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}
int intGet()
{
  int number = 0;
  cout << "Enter an integer: ";
  cin >> number;
  cin.ignore(numeric_limits<int>::max(), '\n');
  if (!cin || cin.gcount() != 1)
     {
     cout << "Please enter a valid integer" << endl; 
     cin.clear();//reset the input flags
     cin.ignore(numeric_limits<int>::max(), '\n');
     return 0;
 
     }
  else
     {return number;}           
}

Doing the better fix will give you more control over user input. The quick fix will solve the endless loop problem...but leaves strange results when entering letters.
Example...when the program says "Your name is, right? 1 = yes 2 = no"
when you input "ddd" it will assume that means yes and move on (for whatever the fing reason) . Clearing the Cin will cut out the endless loop but will not control the user input.

p.s. if someone has a better solution post it...I am wet behind the ears on C++


Top
 Profile  
 
 Post subject: Re: Teh Calc C++
PostPosted: Fri May 15, 2009 5:54 pm 
Offline
Knowledgeable
User avatar

Joined: Sun Apr 13, 2008 12:02 am
Posts: 128
WOW C++ code looks insane...

_________________
Image


Top
 Profile  
 
 Post subject: Re: Teh Calc C++
PostPosted: Fri May 15, 2009 8:42 pm 
Offline
Persistant Poster
User avatar

Joined: Wed Nov 29, 2006 11:25 pm
Posts: 860
Location: Ayer
Nah it's just a different syntax that could take you just about max half an hour to learn.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Teh Calc C++
PostPosted: Thu May 28, 2009 2:22 pm 
Offline
Pro
User avatar

Joined: Tue Apr 22, 2008 2:15 am
Posts: 597
*cough*speakforyourself*cough*

lol, but really, it isn't to bad, just different rules and a lot more picky than VB :D


Top
 Profile  
 
 Post subject: Re: Teh Calc C++
PostPosted: Fri May 29, 2009 3:59 am 
Offline
Community Leader
User avatar

Joined: Sun May 28, 2006 10:29 pm
Posts: 1762
Location: Salt Lake City, UT, USA
Google Talk: Darunada@gmail.com
if you have a real and firm understanding of VB6, learning any other language is tons easier :)

_________________
I'm on Facebook! Google Plus LinkedIn My Youtube Channel Send me an email Call me with Skype Check me out on Bitbucket Yup, I'm an EVE Online player!
Why not try my app, ColorEye, on your Android devlce?
Do you like social gaming? Fight it out in Battle Juice!

I am a professional software developer in Salt Lake City, UT.


Top
 Profile  
 
 Post subject: Re: Teh Calc C++
PostPosted: Fri May 29, 2009 6:13 am 
Offline
Regular
User avatar

Joined: Thu Mar 06, 2008 1:48 pm
Posts: 54
C++ is easier than it looks, Although most people say Memory management is a pain in the ass, i never really made a program that gave me that shit. but thats why Third party garbage collectors exist no? (i personally havent used one, but they sound good.)

_________________
The Apocalypse Is coming!
Code:
[b]The [i][color=#FF0000]Apocalypse[/color][/i] Is coming![/b]

Image


Top
 Profile  
 
 Post subject: Re: Teh Calc C++
PostPosted: Fri May 29, 2009 1:30 pm 
Offline
Pro
User avatar

Joined: Tue Apr 22, 2008 2:15 am
Posts: 597
heh, ya well im not good at any language...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group