Whats wrong - TicTacTo

This is a discussion on Whats wrong - TicTacTo within the C++ Programming forums, part of the General Programming Boards category; What's wrong with the this first part of a game. It everytime says Falsche Ausgabe Code: #include <iostream> using namespace ...

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    1

    Whats wrong - TicTacTo

    What's wrong with the this first part of a game.
    It everytime says Falsche Ausgabe

    Code:
    #include <iostream>
    
    
    using namespace std;
    char f_1 = '1';
    char f_2 = '2';
    char f_3 = '3';
    char f_4 = '4';
    char f_5 = '5';
    char f_6 = '6';
    char f_7 = '7';
    char f_8 = '8';
    char f_9 = '9';
    bool bGameover=false;
    char eingabe;
    char player_turn = '1';
    int Schleife = 1;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    int main (void)
    {
    
    
    do
    {
        
       //Spielfeld
        cout << "==============" <<endl;  
        cout << " | "; 
        cout << f_1; 
        cout << " | ";
        cout << f_2;
        cout << " | ";
        cout << f_3;
        cout << " |  " << endl;
        cout << "==============" <<endl;
        cout << " | ";
        cout << f_4;
        cout << " | ";
        cout << f_5;
        cout << " | ";
        cout << f_6;
        cout << " | " << endl;
        cout << "==============" <<endl;
        cout << " | ";
        cout << f_7;
        cout << " | ";
        cout << f_8;
        cout << " | ";
        cout << f_9;
        cout << " | " << endl;
        cout << "==============" << endl;
        cout << "W?hlen sie ein Feld: ";
        cin >> eingabe;
      
                 if (eingabe == 1 && f_1 == 1 ) {
                f_1= 'x';
                } else if (eingabe == 2 && f_2 == '2') {
                f_2= 'x';
                } else if (eingabe == 3 && f_3 == '3') {
                    f_3= 'x';
                } else if (eingabe == 4 && f_4 == '4' ) {
                    f_4= 'x';
                } else if (eingabe == 5 && f_5 == '5' ) {
                    f_5= 'x';
                } else if (eingabe == 6 && f_6 == '6') {
                    f_6= 'x';
                } else if (eingabe == 7 && f_7 == '7') {
                    f_7= 'x';
                } else if (eingabe == 8 && f_8 == '8') {
                    f_8= 'x';
                } else if (eingabe == 9 && f_9 == '9') {
                       f_9= 'x';
                } else {
                    cout << "Falsche Eingabe" <<endl;
                    
                }
                      
      
      
         
    
    
    }
    while(!bGameover);  
       
     
    
    
       cin.sync();
       cin.get();
       return 0;
    }

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    2,895
    You have declared eingabe as a char but you are trying to compare this character to an int value in your if statements. Also you should move your variable declarations into main(). Using global variables is a bad practice, learn to declare your variables within the smallest scope possible.


    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Whats wrong with my IRC Bot??
    By peradox in forum Networking/Device Communication
    Replies: 8
    Last Post: 05-23-2005, 06:16 PM
  2. Whats wrong with this?
    By blindman858 in forum C++ Programming
    Replies: 4
    Last Post: 05-14-2005, 12:44 AM
  3. whats wrong with this? no errors but wrong result
    By InvariantLoop in forum C Programming
    Replies: 6
    Last Post: 01-28-2005, 12:48 AM
  4. Can anyone see whats wrong here?
    By Alphacentric666 in forum C++ Programming
    Replies: 1
    Last Post: 01-04-2003, 02:54 PM
  5. Whats wrong?
    By Munkey01 in forum C++ Programming
    Replies: 8
    Last Post: 12-23-2002, 11:09 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21