[C++] Wtf is wrong? menu

Shout-Out

User Tag List

Results 1 to 9 of 9
  1. #1
    P1raten's Avatar Banned
    Reputation
    500
    Join Date
    Mar 2008
    Posts
    1,323
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [C++] Wtf is wrong?

    What am i doing wrong?

    Code:
    #include <iostream>
    
    using namespace std;
    
    char Pick;
    
    void OptionA();
    void OptionB();
    void OptionC();
    void OptionAfalse();
    void OptionBfalse();
    void OptionCfalse();
    void YIsTrue();
    void YAIsTrue();
    void YBIsTrue();
    
    bool a = false;
    bool b = false;
    bool c = false;
    
    
    int main() {
    	system("cls");
    	cout<<"a&c = y"<<endl;
    	cout<<"b&c = y"<<endl;
    	cout<<"a = false"<<endl;
    	cout<<"b = false"<<endl;
    	cout<<"c = false"<<endl;
    	cout<<"V'a'lj en bokstav att 'a'ndra\n"<<endl;
    	cin>>Pick;
    	if (Pick == 'a')
    	{
    			OptionA();
    	}
    	if (Pick == 'b')
    	{
    			OptionB();
    	}
    	if (Pick == 'c')
    	{
    			OptionC();
    	}
    }
    
    void OptionA() {
    	if (a)
    	cout << "a is true" << endl;
    	bool a = false;
    	OptionAfalse();
    }
    
    void OptionAfalse() {
    	if (!a)
    	cout << "a is false" << endl;
    	bool a = true;
    	YIsTrue();
    }
    
    void OptionB() {
    	if (b)
    	cout << "b is true" << endl;
    	bool b = false;
    	OptionBfalse();
    }
    
    void OptionBfalse() {
    	if (!b)
    	cout << "b is false" << endl;
    	bool b = true;
    	YIsTrue();
    }
    
    void OptionC() {
    	if (c)
    	cout << "c is true" << endl;
    	bool c = false;
    	OptionCfalse();
    }
    
    void OptionCfalse() {
    	if (!c)
    	cout << "c is false" << endl;
    	bool c = true;
    	YIsTrue();
    }
    
    void YIsTrue() {
    	if ((c) && (a))
    		YAIsTrue();
    	if ((c) && (b))
    		YBIsTrue();
    }
    
    void YAIsTrue() {
    	if (a)
    		cout << "Y is true" << endl;
    		system("pause");
    }
    
    void YBIsTrue() {
    	if (b)
    		cout << "Y is true" << endl;
    		system("pause");
    }
    Last edited by P1raten; 01-16-2010 at 08:43 PM.

    [C++] Wtf is wrong?
  2. #2
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Based on that code, quite a lot.

  3. #3
    P1raten's Avatar Banned
    Reputation
    500
    Join Date
    Mar 2008
    Posts
    1,323
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Cypher View Post
    Based on that code, quite a lot.
    That is not helping at all, cypher.

    If im not mistaking i was asking WHAT is wrong. Meaning that i want something specific.

    If you could help me then i'd really appreciate it.

  4. #4
    Xarg0's Avatar Member
    Reputation
    61
    Join Date
    Jan 2008
    Posts
    389
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You failed at using the compare operator ==, you've used = very often instead of ==
    and what you're doing doesn't have anything to do with programming...
    I hacked 127.0.0.1

  5. #5
    Pragma's Avatar Contributor
    Reputation
    261
    Join Date
    Feb 2007
    Posts
    630
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, you need to know the difference between variable types, a char is not a Boolean value.

    Although Cypher didn't say anything specific, he didn't really need to, your code is about 97% messed up. I suggest starting from the basics with a tutorial from a reputable website or author.


  6. #6
    P1raten's Avatar Banned
    Reputation
    500
    Join Date
    Mar 2008
    Posts
    1,323
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeh, i fixed some parts of it now. But it still doesnt work.

  7. #7
    abuckau907's Avatar Active Member
    Reputation
    49
    Join Date
    May 2009
    Posts
    225
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    void OptionAfalse() {
    if (!a)
    cout << "a is false" << endl;
    bool a = true;
    YIsTrue();
    }
    for 1, you need to surround your "IF" code with brackets. Your code basically ignored the If and runs everything anyway..you need to use brackets like..
    Code:
    IF ( something )
    {
    //do this code if something is truse
    }
    else
    {
    //run this code if something is false
    }
    without the brackets it's just throwing away the If's result then calling the below code unconditionally. (Unless you have a 1-liner after the If..then you need no brackets?) Also..at the top you declared 'Bool a', then in this code you say 'bool a = True' --> Are you trying to re-declare a (ie. new variable), because I think you just made a 2nd variable (local scope) w/ the same name..maybe that's what you were trying to do?

  8. #8
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You asked a stupid question so I gave a stupid answer.

    Don't post a giant slab of code and say "what is wrong". That's retarded. We're not mind readers, so give some specifics, ask some actual questions, not giant blanket questions.

    Also, get yourself a reputable C++ book to learn from, as your code just reeks of someone who is trying to "teach themselves" and doing a very bad job of it.

    I'll help you, but only if you help yourself first.

  9. #9
    P1raten's Avatar Banned
    Reputation
    500
    Join Date
    Mar 2008
    Posts
    1,323
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Cypher View Post
    You asked a stupid question so I gave a stupid answer.

    Don't post a giant slab of code and say "what is wrong". That's retarded. We're not mind readers, so give some specifics, ask some actual questions, not giant blanket questions.

    Also, get yourself a reputable C++ book to learn from, as your code just reeks of someone who is trying to "teach themselves" and doing a very bad job of it.

    I'll help you, but only if you help yourself first.
    Appreciate that you are willing to help me cypher.

    I fixed it myself however.

    Had to re-write it twice. ^^

Similar Threads

  1. WOW whats wrong WTF?
    By dUcKyDrEaMeRx3 in forum Community Chat
    Replies: 3
    Last Post: 12-18-2008, 08:37 AM
  2. Wtf am I doing wrong...?
    By jts5676 in forum World of Warcraft General
    Replies: 6
    Last Post: 03-23-2008, 06:35 AM
  3. wtf anyone know where to get this ?
    By Skalla in forum World of Warcraft General
    Replies: 7
    Last Post: 09-01-2006, 03:25 AM
  4. Whats wrong with my video card?
    By Matt in forum Community Chat
    Replies: 2
    Last Post: 07-20-2006, 03:17 AM
  5. When buying an Account goes wrong
    By karokekid in forum Community Chat
    Replies: 5
    Last Post: 07-12-2006, 05:54 PM
All times are GMT -5. The time now is 06:29 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search