Simple Array

I'm trying to write a blackjack program, in which i'm shuffling cards, dealing, and determining whether or not to take another card. I'm making the cards a bi-dimensional array, and i can't seem to get the array to work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<iostream>

using namespace std;

int main(int argc, char * argv[]){

   //declaring suits
   double H=20, S=21, D=22, C=23;

  //making the array
  double card[4][4] = {{H,1},{H,2},{H,3},{H,4},{S,1},{S,2},{S,3},{S,4},{D,1},{D,2},{D,3},{D,4},{C,1},{C,2},{C,3},{C,4}};

  return 0;
}


It's telling me i've got too many initializers for double[10][10]
Last edited on
In your post, you wrote double[10][10], but in the code you have double[4][4], but the initializer is actually [2][16].

Try declaring it as sinply card[][], without specifying the sizes. Not sure if it will work though. You can also try card[2][].

Btw: double is used for floating point numbers, like 1.5, 3.14 etc. You probably want int.
Last edited on
Topic archived. No new replies allowed.