whats this error all about?

Jul 20, 2009 at 7:40pm
this is somewhat confusign to me. ive made my deck of cards and tried to just run a cout to make sure that everything is set correctly in my deck. everytime i run it though, this is what i get. (ill list the code, followed by the error)....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// BlackJack.cpp : Defines the entry point for the console application.
//

#include <stdafx.h>
#include <stdlib.h> //needed for rand() and srand()
#include <iostream>
#include <string.h>
#include <cmath>
using namespace std;

char cardvalue[52]= { '2', '2', '2', '2', '3', '3', '3', '3', '4', '4', '4', '4', '5', '5', '5', '5', 
'6', '6', '6', '6', '7', '7', '7', '7', '8', '8', '8', '8', '9', '9', '9', '9', 't', 't', 't', 't', 'j', 'j', 'j', 'j',
'q', 'q', 'q', 'q', 'k', 'k', 'k', 'k', 'a', 'a', 'a', 'a' } 

int main()
{
cout<< "The array consist of: " << cardvalue << endl;
}


the error is....

c:\documents and settings\misty\my documents\visual studio 2008\projects\blackjack\blackjack\blackjack.cpp(15) : error C2144: syntax error : 'int' should be preceded by ';'
Jul 20, 2009 at 7:42pm
You forgot the semicoloin after the final bracket of the cardvalue array initialization.
Jul 20, 2009 at 7:57pm
yes Kempo, i just got that. thanks so much. my next question is if someone might be able to help me figure out how exactly to shuffle and deal the deck. ive got several of my other needed functions done already, but this one is really holding me up.

Thanks agian for any help!
Jul 20, 2009 at 9:13pm
if someone might be able to help me figure out how exactly to shuffle


What a conveniently named function we have here: http://cplusplus.com/reference/algorithm/random_shuffle/
Jul 20, 2009 at 10:18pm
Random shuffle needs iterators...and you don't have iterators in an array...

Read jsmith's post
Last edited on Jul 20, 2009 at 10:30pm
Jul 20, 2009 at 10:21pm
random_shuffle needs random access iterators, and pointers fit the bill.

random_shuffle( &cardvalue[0], &cardvalue[52] );

will work just fine.

Topic archived. No new replies allowed.