Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Vairables not registering? C++ [Solved]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Chase Payne
Grandmaster Cheater
Reputation: 1

Joined: 20 Mar 2008
Posts: 533

PostPosted: Thu Aug 20, 2009 5:59 pm    Post subject: Vairables not registering? C++ [Solved] Reply with quote

>.> this is my second day on learning C++ ( I don't know charter strings YET)


But how do I get this to work correctly? All it does is return 0-0, 0+0... etc.


Code:
#include "stdafx.h"
#include <iostream>
int X;
int Y;
int checker();
int chChoice;
char YNyes;


int main()
{
    using namespace std;
    cout << "Enter a value: ";
    cin >> X;

    cout << "Enter a second value: ";
    cin >> Y;
   checker();
}
int checker()
{
   using namespace std;
   cout << "\nEnter one of the following: +, -, *, or /";
    char chChoice;
    cin >> chChoice;
    if (chChoice == '+')
   {
        cout << X << " + " << Y << " is " << (X + Y) << endl;
      cout << "Would you like to enter another equation!?\n Enter as Y/N.\n";
      char YNyes;
        cin >> YNyes;
      if (YNyes == 'y')
      main();
      else
         cout << "\nOkay, you made it clear you don't\n";
        return 0;
   }
    if (chChoice == '-')
   {
        cout << X << " - " << Y << " is " << (X - Y) << endl;
      cout << "Would you like to enter another equation!?\n Enter as Y/N.\n";
      char YNyes;
        cin >> YNyes;
      if (YNyes == 'y')
      main();
      else
         cout << "\nOkay, you made it clear you don't\n";
        return 0;
      return 0;
   }
    if (chChoice == '*')
   {
        cout << X << " * " << Y << " is " << (X * Y) << endl;
      cout << "Would you like to enter another equation!?\n Enter as Y/N.\n";
      char YNyes;
        cin >> YNyes;
      if (YNyes == 'y')
      main();
      else
         cout << "\nOkay, you made it clear you don't\n";
        return 0;
   }
    if (chChoice == '/')
   {
        cout << X << " / " << Y << " is " << (X / Y) << endl;
      cout << "Would you like to enter another equation!?\n Enter as Y/N.\n";
      char YNyes;
        cin >> YNyes;
      if (YNyes == 'y')
      main();
      else
         cout << "\nOkay, you made it clear you don't\n";
        return 0;
      return 0;
   }
   else
   {
      cout << "Sorry, invalid character.\t\t\t\t";
      checker();
       return 0;
 }
}




Nevermind, I found the problem


I used double x and y twice by accident... after declaring it lol
Back to top
View user's profile Send private message
hacksign23
Master Cheater
Reputation: 0

Joined: 26 Nov 2006
Posts: 404

PostPosted: Sat Aug 22, 2009 10:51 pm    Post subject: Reply with quote

good, good

btw, you can put your
using namespace std;
between
char YNyes;
and
int main()

and you won't have to put it anywhere else. it makes it global.

_________________
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites