Help With Maintaining User Input

This is a discussion on Help With Maintaining User Input within the C++ Programming forums, part of the General Programming Boards category; Hey, I'm currently working on learning C++ and I've started a project of creating a Tic-Tac-Toe game from scratch. Currently ...

  1. #1
    Registered User BKW++'s Avatar
    Join Date
    Feb 2009
    Location
    South Carolina
    Posts
    3

    Arrow Help With Maintaining User Input

    Hey, I'm currently working on learning C++ and I've started a project of creating a Tic-Tac-Toe game from scratch. Currently I'm having problems with my user's input getting overrided. I have my variables limited using != , but the rand() sometimes takes the place of a already used user inputted value value.

    I uploaded the current file of my project. If you compile and run it a few times you would understand what I mean if you already don't.

    Simply put if I wrote X like below:
    Code:
     X |   |   
    ___|___|___
       |   |   
    ___|___|___
       |   |   
       |   |
    Then later in my program it gets replaced:
    Code:
     O |   |   
    ___|___|___
       |   |   
    ___|___|___
       |   |   
       |   |
    Even though, I limited the variables:
    Code:
    opp_input4 = !(input, input2, input3, input4, opp_input, opp_input2, opp_input3);
    So if anyone can tell what I'm doing wrong or what I need to add then that would be very good. I'm almost done with the coding, and this is about the only thing holding me back.

    Thanks,
    BKW[ATTACH]TTT.cpp[/ATTACH]

  2. #2
    30 Helens Agree neandrake's Avatar
    Join Date
    Jan 2002
    Posts
    640
    Quote Originally Posted by BKW++ View Post
    Even though, I limited the variables:
    Code:
    opp_input4 = !(input, input2, input3, input4, opp_input, opp_input2, opp_input3);
    Is this legal syntax for checking against numerous cases?
    Environment: OS X, GCC / G++
    Codes: Java, C#, C/C++
    AOL IM: neandrake, Email: neandrake (at) gmail (dot) com

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by neandrake View Post
    Is this legal syntax for checking against numerous cases?
    It is legal syntax, but it probably doesn't do what the original poster wanted, as
    Code:
    opp_input4 = !(input, input2, input3, input4, opp_input, opp_input2, opp_input3);
    is equivalent of:
    Code:
    input, input2, input3, input4, opp_input, opp_input2;
    opp_input4 = !(opp_input3);
    The first of those two lines is completely pointless (except the compiler MAY cause some memory read operations to access the varaibles...)

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  3. SSH Hacker Activity!! AAHHH!!
    By Kleid-0 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 03-06-2005, 02:53 PM
  4. Nested Structures - User Input
    By shazg2000 in forum C Programming
    Replies: 2
    Last Post: 01-09-2005, 09:53 AM
  5. ~ User Input script help~
    By indy in forum C Programming
    Replies: 4
    Last Post: 12-02-2003, 05:01 AM

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