C++ beginner here is it possible to call a function within another function?

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

void displayRules();
void play(int cardPile[]);
int shuffleCard(int cardPile[]);


int main()
{
    int board[26] = {0, 1, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0};
    int cardPile[10] = {1, 1, 2, 2, 3, 3, 4, 4, 0, 5};
    int player1 = 0;
    int player2 = 0;

    play(cardPile);


    return 0;
}

void play(int cardPile[]){
    displayRules();
    shuffleCard(cardPile);

}

void displayRules(){
    cout << "\nWelcome to GoHome! The main objective of this game is to reach Home"
            " first." << endl;
    cout << "The basic rules of the game are as follows:" << endl;
    cout << "\n-To begin the player with the shortest name goes first." << endl;
    cout << "-Each player picks a card that has a number on it and the player"
            " must moves forward that many number of spaces." << endl;
    cout << "-If a card says 'Lose A Turn', the player does nothing and the"
            "turn moves to the next player." << endl;
    cout << "-If a card says 'Switch Places', that player is allowed to switch"
            " places with any player on the board." << endl;
    cout << "-If a player lands on an obstacle, that player must move back that"
            " many number of spaces." << endl;
    cout << "-If a player lands another obstacle while moving backwards, then it"
            " does not have to move backwards again.\n"<<endl;
}

int shuffleCard(int cardPile[]){

    srand(time(0));
    for(int i = 0; i < 10; i++){
            int size = rand() % 10;
        cout << cardPile[size] << endl;
    }
}

Leave a Comment