vendredi 7 avril 2017

How to make an array in a function in C++?

What I'm trying to output is the dealer's roll (the numbers are supposed to be stored in an array) but I keep getting an error that int is an invalid type in "DealerRoll(dealerRoll[3]);"

#include <iostream>
#include <time.h>
#include <stdio.h>      
#include <stdlib.h>  
using namespace std;

//Dice Rolls
int DealerRoll(int dealerRoll[3])
{
        srand (time(NULL));
    for (int dealerCount = 0; dealerCount < 3; dealerCount++)
    {
    dealerRoll[dealerCount] = rand()% 6+1;
    cout << dealerRoll[dealerCount] << " ";
    }
    return dealerRoll[3];
}

int main()
{
    int dealerRoll;

    cout << "Dealer's Roll: " << endl;
    DealerRoll(dealerRoll[3]);

system ("pause");
return 0;
}




Aucun commentaire:

Enregistrer un commentaire