The idea of the entire program is to play a simplified version of war that's why its 28 cards. Anyway my problem comes from the dealRandomCard function when I compile it it says there needs to be another ) before time. I'm not sure what to do.

I appreciate the help so thank you in advance.

#include <cstdlib>
#include <ctime>
#include <iostream>

void dealCardSet(int [], int [], int [], int [], int);
void dealRandomCard(int [], int [], int [], int [], int);

int main(){

int cards;
int P1Cards[cards], P1Suit[cards], CompCards[cards], CompSuit[cards];

dealCardSet(P1Cards, P1Suit, CompCards, CompSuit, cards);

return 0;
}

void dealCardSet(int P1Cards[], int P1Suit[], int CompCards[], int CompSuit[], int cards){

cout << " How many cards do you want to play?(1-28)   ";
cin >> cards;

for (int i=0;i<cards;i++)
     dealRandomCards(P1Cards, P1Suit, CompCards, CompSuit, cards);

}

void dealRandomCard(int P1Cards[], int P1Suit[], int CompCards[], int CompSuit[], int cards){

for(int i = 0; i<cards; i++){
     srand((P1Cards[i])time(0));
     srand((CompCards[i]time(0));
     for (int index=0; index<cards;index++){
          P1Cards[i]=(rand()%14)+1;
          CompCards[i]=(rand()%14)+1;
          Cout << P1Cards[i];
           Cout << CompCards[i];
          }
     }


for(int j = 0; j<cards; j++){
     srand((P1Suit[j])time(0));
     srand((CompSuit[j]time(0));
     for (int index2=0; index2<cards;index2++){
          P1Suit[j]=(rand()%14)+1;
          CompSuit[j]=(rand()%14)+1;
          Cout << P1Suit[j];
           Cout << CompSuit[j];
          }
     }
srand((P1Cards[i])time(0));

What are you trying to do here? Either seed the RNG with time (0) or with P1Cards, but not both.

First off you need to read the srand information on the web
try http://www.cplusplus.com/reference/clibrary/cstdlib/srand.html and understand that you are setting a seed.
That means do it once and unless you want the same numbers again do not do it twice. Since you are setting it with time(0) and most short programs take less than 1sec to run you will re-set the random number seed to the same number if you use it twice in the program.

Additionally, if you look on the web page you will see that srand takes an integer so why you are trying to cast is to something I have no idea
use: srand(time(0); or use srand(34567); were 34567 is an integer of your choosing so that you get the same number each time. (Excellent for debugging). Put the single call to srand in main() so that you are certain it is called once only.

You have a number of other errors and since this is a c++ forum you might want to think about getting you code into some object orientated form. e.g. have card class and a deck class maybe.

Additionally, I don't understand the rand() % 14 part since you have 28 cards but maybe it is just that I don't know how to play war (and I haven't look it up).

First off I forgot to mention I am quite the beginner at c++ this is the first class I've taken on it.

So I need to take out the srands that are in the function but then how do I put it in the main. is it something like

int random=4;
srand(random);

ok so I put that in the main and got it to work. I left everything the same in the dealRandomCard function, but now the compSuit is outputting to exponents.

The rand()%14 and rand()%3 are the face values and the suit values.
the 14 are 2-10 and j,q,k,a being 11,12,13,14
the suits are 0-3 Hearts, clubs, diamonds, and spades.

the output is giving me results for only the %3 one nothing for the %14.

About classes my class hasn't learned those yet so I don't think I'm supposed to use them. I'm sure he'd be thoroughly impressed but I have no idea what you mean.

oh and it doesn't matter if there are doubles or triples of cards.

First off I forgot to mention I am quite the beginner at c++ this is the first class I've taken on it.

So I need to take out the srands that are in the function but then how do I put it in the main. is it something like

int random=4;
srand(random);

???
and then do I leave it the same in the function?

int main ()
{
     srand (time (0)); // top line in main

     // more code in main
}

Take all other srand code out of the program except for the single line above.

This article has been dead for over six months. Start a new discussion instead.