Got an error with me' code.... was wondering if someone could take a look at the method behind my madness...
Here is the code so far.. This code is a prototype for a function that I hope to use in my blackjack program. Hopefully, this will allow me to do something like...
cout << deck[1][5] to display "7 of Diamonds" for example.
Code:
#include<cstring> //provides strcat()
#include<string> //provides string class
using namespace std;
int main()
{
string deck[3][12]; //create a deck of cards, 4 suits, 13 cards per suit (2 thru Ace)
string suite, face_value, card;
for (int i = 0; i < 4; i++) //Use the outter FOR loop to determine the suite of deck[suite][face_value]
{
switch(i)
{
case 0: suite = "Hearts";
break;
case 1: suite = "Diamonds";
break;
case 2: suite = "Clubs";
break;
case 3: suite = "Spades";
break;
}//end switch
for (int j = 0; j < 13; j++) //The Inner FOR loop will assign card face values
{
int k = j; //this allows me to add "2" to the j counter without influencing the FOR loop.
if (j < 9) //elements [0] thru [8] can be populated with numbers 2 thru 10 (numeric card face values)
face_value = (k + 2); //this allow element zero to contain face value "2"
else
{
switch(j)
{
case 9: face_value = "Jack";
break;
case 10: face_value = "Queen";
break;
case 11: face_value = "King";
break;
case 12: face_value = "Ace";
break;
}//end switch
}//end else
//This block will create a "card" to be assigned to the deck
card = face_value;
strcat(card, " of ");
card += suite;
deck[i][j] = card;
}//end INNER FOR
}//end OUTTER FOR
return 0;
}//end MAIN()
Here is the error I be gettin'... using MS visual C++
--------------------Configuration: bj - Win32 Debug--------------------
Compiling...
shuffletest.cpp
C:\MySource\shuffletest.cpp(67) : error C2664: 'strcat' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
shuffletest.obj - 1 error(s), 0 warning(s)
Please help if you can