Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • gogata: holy crap time to make a rsps again 10 years later since i made this acc LOL
      Today at 03:23:51 PM
    • hodford: yo autoscape has keylogger in cache, ive been member in this community since 2011
      August 20, 2019, 08:57:42 PM
    • E S C O B A R: Anyone able to help me, i'm trying to find a decent source/client to start from , I haven't been near a laptop in over two years . Does much people still play RSPS's also?
      August 19, 2019, 04:52:38 PM
    • dan v jad: Great osrsps experience - check us out - join on discord! dxp, dpoints [link]
      August 19, 2019, 09:50:00 AM
    • ragnoroker: Brand new server! Double EXP is enabled right now aswell as other events! - [link]
      August 18, 2019, 07:14:43 AM
    • ragnoroker: Brand new server! Double EXP is enabled right now aswell as other events! - [link]
      August 18, 2019, 07:14:35 AM
    • puppajohn: Come and join us today for amazing content !
      August 16, 2019, 10:26:16 PM
    • puppajohn:[link] come and join us now! you have donator on your server? no problem we restore your donator credits and symbol ! free M box on loggins
      August 16, 2019, 10:26:02 PM
    • PavSwag: autoscape,0rg kill REVS for chance of TWISTED BOW || EP GETS YOU OSRS GP TOKENS
      August 15, 2019, 05:13:07 PM
    • hodford: autoscape,0rg is actually fudgein lit as come check it out
      August 13, 2019, 02:59:58 AM
    • ragnoroker: Brand new server! Hosting Raids Event all day + More! - 20+ online, Join today [link]
      August 11, 2019, 07:45:49 AM
    • ragnoroker: Brand new server! Hosting Raids Event all day + More! - 20+ online, Join today [link]
      August 11, 2019, 07:45:46 AM
    • PavSwag: autoscape,0rg kill REVS for chance of TWISTED BOW
      August 08, 2019, 07:29:43 PM
    • ragnoroker:Brand new server! Endless Content - Mature Players/Staff - 20+ online, Join today [link]
      August 08, 2019, 11:05:53 AM
    • ragnoroker:Brand new server! Endless Content - Mature Players/Staff - 20+ online, Join today [link]
      August 08, 2019, 11:05:46 AM
    • asshole_rule: bernie sanders
      August 06, 2019, 07:54:02 PM
    • PavSwag: #AS 100M OSRS GP GIVEAWAY!! [link] 317 Oldschool RuneScape Private Server emulating core factors of the game with a strong economy and balance of experience to bossing and prestiging -Receive DONATOR Perks by maxing to 99s- Lumbridge remade - Login with a starter set of armour and items - PK District - Preloading sets - Activity points for training - All Skills Working, Skilling Island, Skilling Pets, Skilling Rewards - All Working Max Capes - 25+ Bosses with Pets - Superior Slayer Encounters - Player Owned Shops - Minigames, Construction, Sawmill, Warriors Guild, Pest Control, Barrows (with pets), Fight Caves, Inferno Caves, Chambers of Xeric, Custom Raids - NPC Drop Table, Kills Tracker, Points Tracker, Extra settings. - Doubled Xp & Points Weekends - Vote System - Vote4Donor - Competitive Highscores - Tons of Content - Join us today for bonus giveaways and free ultra mystery box upon login!   Official YouTube Media: [youtube]P5D0eXEmjA4[/youtube] Join NOW Ill personally give you Ultra Mystery Boxes (Twisted Bow??) Im the Developer :smiley: Heres the Discord:  [link] BTW 100m OSRS GP Giveaways WEEKLY!
      August 05, 2019, 01:05:53 PM
    • ragnoroker: Brand new server! Endless Content - Mature Players/Staff - 20+ online, Join today :) - [link]
      August 05, 2019, 12:48:52 PM
    • ragnoroker: Brand new server! Endless Content - Mature Players/Staff - 20+ online, Join today :) - [link]
      August 05, 2019, 12:48:47 PM
    • suelo: does the search not work on here?
      August 05, 2019, 02:12:08 AM

    Author Topic: Tic-Tac-Toe C++ Passing 2D Arrays  (Read 2192 times)

    0 Members and 1 Guest are viewing this topic.

    Offlinerobonick8

    • Member
    • ***
    • Posts: 128
    • Thanks: +0/-0
      • View Profile
    Tic-Tac-Toe C++ Passing 2D Arrays
    « on: March 09, 2017, 02:38:11 PM »
    Hello Moparscape,

    I am currently making a tic-tace-toe project just for practice
    So far I have the board made which looks like
    Code: [Select]
    void printBoard() {
    for (int i = 0; i < row; i++) {
    for (int j = 0; j < col; j++) {
    cout << " | " << game[i][j] << " | ";
    }
    cout << endl;
    }
    }
    Outputs:
    1 2 3
    4 5 6
    7 8 9

    So now the next step I was going to do was create the function for the User input to where they want to place there x or o. So far I have
    Game.cpp
    p1 is X and p2 is O
    Code: [Select]
    void userInput(char ** g, char p1, char p2) {
    int a;
    cout << "Enter in number on the board." << endl;

    switch (a) {
    case 1:
    ** g = p1;
    break;
    }

    }
    I know Im missing the rest but I am trying to use a switch statement instead of a bunch of if else statements. My problem is how do I pass a 2D Array and use it in the switch statement to replace the number on the board with the X or O? I am using multiple files Main.cpp Game.cpp and Game.h
    Runescape Gambling

    Offlinerunegay

    • Member
    • ****
    • Posts: 349
    • Thanks: +0/-0
      • View Profile
    Re: Tic-Tac-Toe C++ Passing 2D Arrays
    « Reply #1 on: March 11, 2017, 12:46:05 AM »
    you dont need switch statements or a an if-else block. Just take the users input, and then convert the data to an integer, and then pass the data to a function which modifies the underlying 2d array.
    The CIA hacked my fleshlight and it ripped my dick off
    Runescape Gambling

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal