I have a question regarding random number generators. I have already looked at the thread teaching me how to generate random numbers. My question is, is there a way for the generator to only generate one number 4 times? i am trying to randomly generate a deck of cards where the generated numbers are 1 - 12. Since in a real deck there is only four of each cards, I am wondering if this is possible.

Thanks in advance

Austin

P.S. please don't scold me for posting the same thing again since all the other threads are old, i did not want to ressurect old threads.

Create a class called 'deck'
Initialise it with 52 cards.

Implement a function called 'shuffle', which randomises the order of 52 cards.

Implement a function called 'deal', which gives the next card in the pack. Calling deal 52 times will give you the whole pack, in a random order.

You don't need a random number generator with a series of magic properties.

>>i did not want to ressurect old threads.
Good -- you might have teen tounglashed had you done that :)

Write a function that keeps track of all the random numbers it creates. Put the numbers into an array then each time a number is generated search the array to see how many times that number has been generated. You want the numbers 1-12 then create an int array of 12 elements and initialize them to zero. If you generate the number 2 then you will increment the 2nd element of the array -- array[1] is the 2nd array element.

int array[12] = {0};
..
int gennum()
{
   while(1)
   {
        int n = rand() % 12 + 1;
        if( array[n-1] < 4)
        {
            array[n-1]++;
            return n;
        }
  
}

Create a class called 'deck'
Initialise it with 52 cards.

Implement a function called 'shuffle', which randomises the order of 52 cards.

Implement a function called 'deal', which gives the next card in the pack. Calling deal 52 times will give you the whole pack, in a random order.

any way you could help me do that? i am kind of a novice.

Here's the basic class. You'll have to fill in the shuffle routine. As an aside, normal decks have 52 cards, which would be the numbers 1-13, not 1-12.

class Deck{
public:
   list<int> cards;  // cards in the deck
   
   void init(){      // puts all 52 cards in deck
      cards.clear(); // start with an empty deck
      
      for(int i = 0; i < 52; i++){  // fill it with 52 cards
         cards.push_back((i/4)+1);  // numbers 1-13 only
         }
      }
   
   void shuffle(){
      // .. shuffle deck randomly here
      }
   
   int getTopCard(){// deal a card - i.e. get top card, remove it from the deck
      int ret = 0;
      
      if(cards.size() > 0){
         ret = cards.front();
         cards.erase(cards.begin();
         }
      
      return ret;    // return 0 if no more cards, or the top card
      }
      
   Deck(){           // constructor
      init();           // fill the deck
      shuffle();     // shuffle it
      }
   };

To use it in the program:

int main(){
   Deck myDeck;   // create a shuffled deck

   cout << "Top card is " << myDeck.getTopCard() << endl;
   }

thanks for the help

my shuffling code is this:

{
    int deck[52];    // array of cards;
    srand(time(0));
    
    do 
	{    
        // Shuffles cards
        for (int index=0; index<(52-1); index++) 
		{
            int r = index + (rand() % (52-index));
            int temp = deck[index]; deck[index] = deck[r]; deck[r] = temp;
        }
    }
}

is there any way to use this in the code you gave me?

Yeah. Put it in the shuffle member function of the Deck class.

Because you're using the [] (which can't be used on lists), change the list<int> cards; to vector<int> cards; , and ret = cards.front(); cards.erase(cards.begin(); to ret = cards.back(); cards.pop_back(); .

Yeah. Put it in the shuffle member function of the Deck class.

Because you're using the [] (which can't be used on lists), change the list<int> cards; to vector<int> cards; , and ret = cards.front(); cards.erase(cards.begin(); to ret = cards.back(); cards.pop_back(); .

i tried that and im confused as what to do with the array i created. Also, im using Microsoft visual C++ 2008 and it doesnt seem to like your code. Is there any specific thing i need to include?

i tried that and im confused as what to do with the array i created. Also, im using Microsoft visual C++ 2008 and it doesnt seem to like your code. Is there any specific thing i need to include?

Did you put these lines at the top?

#include <vector>
using namespace std;

http://www.cplusplus.com/reference/stl/vector/
If you have, can you post the revised code and be more specific on the error(s)?

The vector holds all the cards in the deck. You can shuffle its contents, and pick out a card (easiest to do this from the back of the vector - i.e. the last element in it).

You'll likely need to include:

#include <vector>
using namespace std;

at the top of your program.

As you haven't included your code or the errors you got, I can't help further.

Here are the many error messages i got. The code is around 300 some lines so if you want to see it i can post it but just ask.

1>------ Build started: Project: FinalProject, Configuration: Debug Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>Source.cpp
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(29) : error C2664: 'carddeck' : cannot convert parameter 1 from 'int' to 'int []'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(30) : error C2664: 'comp' : cannot convert parameter 1 from 'int' to 'int []'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(57) : error C2664: 'cards' : cannot convert parameter 1 from 'int' to 'int []'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(63) : error C2664: 'cards' : cannot convert parameter 1 from 'int' to 'int []'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(69) : error C2064: term does not evaluate to a function taking 6 arguments
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(94) : error C2664: 'cards' : cannot convert parameter 1 from 'int' to 'int []'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(103) : error C2664: 'cards' : cannot convert parameter 1 from 'int' to 'int []'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(269) : warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(290) : error C2059: syntax error : '}'
1>Build log was saved at "file://c:\Documents and Settings\Austin\Desktop\Austin\FinalProject\Debug\BuildLog.htm"
1>FinalProject - 8 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The problem's in your code; without seeing your code it's a bit hard to see where the problem is...

This is all that's required in the shuffle member function:

void shuffle(){
// Shuffles cards
        for (int index=0; index<(52-1); index++){
            int r = index + (rand() % (52-index));
            int temp = deck[index]; deck[index] = deck[r]; deck[r] = temp;
            }
        }

The 'do' block must be closed with a 'while();'. The 'int deck[52]' isn't required in the shuffle function, as all the cards in the deck are stored in the class already in the vector.

It's best if you attach your code, otherwise it's harder to help. There's an attach icon (paperclip) available when you reply to thread.

here is my code.

SOurce.cpp

deck.h

Attachments
#ifndef _DECK_H
#define _DECK_H

class Deck
{
public:
   vector<int> cards;  // cards in the deck
   
   void init()	// puts all 52 cards in deck
   {      
      cards.clear(); // start with an empty deck
      
      for(int i = 0; i < 52; i++)
	  {  // fill it with 52 cards
         cards.push_back((i/4)+1);  // numbers 1-13 only
	  }
   }
   
   void shuffle()
	{
		int deck[52];
		srand(time(0));
		
		do 
		{    
			// Shuffles cards
			for (int index=0; index<(52-1); index++) 
			{
			    int r = index + (rand() % (52-index));
			    int temp = deck[index]; deck[index] = deck[r]; deck[r] = temp;
			}
		}
	}
   
   int getTopCard()  // deal a card - i.e. get top card, remove it from the deck
   {
      int ret = 0;
      
      if(cards.size() > 0)
	  {
         ret = cards.back(); 
		 cards.pop_back();
      }
      
      return ret;    // return 0 if no more cards, or the top card
      }
      
   Deck()   // constructor
   {           
      init();        // fill the deck
      shuffle();     // shuffle it
   }
};
#endif
//Source.cpp
//Austin
//Mar. 25, 2008
//Im not a very experianced programmer so i have been trying to run the program with functions.  
//the finished product will need a class.

#include <iostream>
#include <iomanip>
#include <time.h>
#include <vector>
#include "deck.h"
using namespace std;

void intro();
void carddeck(int deck[53]);
void cards(int deck[53], int howmany, int count, int player, int total1, int total2);
void comp(int deck[53], int howmany, int count, int player, int total1, int total2);
void player(int deck[53], int howmany, int count, int player, int total1, int total2);
void winlose(int total1, int total2);

int main()
{
	int deck[53];
	int howmany = 0;
	int count = 1;   //keeps track of the cards that have been removed from deck
	int total1 = 0;
	int total2 = 0;
	int player = 0;
	intro();
	carddeck(deck[53]);
	comp(deck[53], howmany, count, player, total1, total2);
	
	
	return 0;
}
/*************************************************************/
void intro()
{
	cout<<"Hello and welcome to: "<<endl<<endl;
	cout<<" ----    |      / \\    ---  |  /     |   / \\     ---  |  / "<<endl; 
	cout<<" |   |   |     |   |  |     | /      |  |   |   |     | /  "<<endl;
	cout<<" |--<    |     |---|  |     |/       |  |---|   |     |/   "<<endl;
	cout<<" |   |   |     |   |  |     | \\   |  |  |   |   |     | \\  "<<endl;
	cout<<" ----    ----  |   |   ---  |  \\   --   |   |    ---  |  \\ "<<endl;
	cout<<"\n                                         Casino Style      "<<endl<<endl;
	cout<<"In the game of Blackjack the object is to beat the dealer. You "<<endl;
	cout<<"will be dealt two cards and so will the dealer.  The object is"<<endl;
	cout<<"to get ""BlackJack"" or 21 points or beat the dealer by getting a "<<endl;
	cout<<"higher score without ""Busting"" (or going over 21). "<<endl<<endl;
}
/*************************************************************/
void comp(int deck[53], int howmany, int count, int player, int total1, int total2)
{
	cout<<"The computer will start: "<<endl;
	char answ;
	player = 1;
	howmany = 2;
	cards(deck[53], howmany, count, player, total1, total2);
	do
	{
		if (total1 <= 16)
		{
			howmany = 1;
			cards(deck[53], howmany, count, player, total1, total2);
		}
		else
		{
			if (total1 <=21)
			{
				player(deck[53], howmany, count, player, total1, total2);
			}
			else
			{
				cout<<"The computer has BUSTED "<<endl;
				cout<<"YOU WIN!!!!!!! "<<endl<<endl;
				cout<<"Would you like to play again? (y/n) ";
				cin>>answ;
				if (answ == 'y')
				{
					int main();
				}
			}
		}
	}
	while((total1 <= 16)&&(total1 <= 21));
}
/*************************************************************/
void player(int deck[53], int howmany, int count, int player, int total1, int total2)
{
	cout<<"Now its your turn: "<<endl;
	cout<<"Here are your cards: "<<endl<<endl;
	char ans;
	player = 2;
	howmany = 2;
	cards(deck[53], howmany, count, player, total1, total2);

	do
	{
		cout<<"Would you like to hit? (y/n) ";
		cin>>ans;
		if ((ans = 'y')&&(total2 >= 21))
		{
			howmany = 1;
			cards(deck[53], howmany, count, player, total1, total2);
		}
		else
		{
			cout<<"You BUSTED..."<<endl;
			winlose(total1, total2);
		}
	}
	while((ans = 'y')&&(total2 <=21));
}
/*************************************************************/
void cards(int deck[53], int howmany, int count, int player, int total1, int total2)
{	//displays a text image of a card instead of a number
	int choice;
	int counter = 0;
	
	do
	{
		choice = deck[count];
		
		if (player == 1)
		{
			total1 = total1 + deck[count];
		}
		if (player == 2)
		{
			total2 = total2 + deck[count];
		}
		count++;

		switch (choice)
		{
		case 1:
			cout<<"  _________  "<<endl;
			cout<<"  |A      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  | (11)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      A|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 2:
			cout<<"  _________  "<<endl;
			cout<<"  |2      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (2)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      2|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 3:
			cout<<"  _________  "<<endl;
			cout<<"  |3      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (3)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      3|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 4:
			cout<<"  _________  "<<endl;
			cout<<"  |4      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (4)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      4|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 5:
			cout<<"  _________  "<<endl;
			cout<<"  |5      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (5)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      5|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 6:
			cout<<"  _________  "<<endl;
			cout<<"  |6      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (6)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      6|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 7:
			cout<<"  _________  "<<endl;
			cout<<"  |7      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (7)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      7|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 8:
			cout<<"  _________  "<<endl;
			cout<<"  |8      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (8)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      8|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 9:
			cout<<"  _________  "<<endl;
			cout<<"  |9      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (9)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      9|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 10:
			cout<<"  _________  "<<endl;
			cout<<"  |10     |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  | (10)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |     10|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 11:
			cout<<"  _________  "<<endl;
			cout<<"  |J      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  | (10)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      J|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 12:
			cout<<"  _________  "<<endl;
			cout<<"  |Q      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  | (10)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      Q|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 13:
			cout<<"  _________  "<<endl;
			cout<<"  |K      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  | (10)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      K|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		default:
			cout<<"  _________  "<<endl;
			cout<<"  |       |  "<<endl;
			cout<<"  |       |  "<<endl;
			cout<<"  | ERROR |  "<<endl;
			cout<<"  |       |  "<<endl;
			cout<<"  |       |  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		}
		counter++;
	}
	while(counter < howmany);
}
/*************************************************************/
void carddeck(int deck[53])
{
    srand(time(0));

    for (int index = 1; index < 53; index++) 
	{
        deck[index] = index;  // fill the array in order 1-52
    }
    
    do 
	{    
        // Shuffles cards
        for (int index = 1; index < (53-1); index++) 
		{
            int r = index + (rand() % (53-index));
            int temp = deck[index]; deck[index] = deck[r]; deck[r] = temp;
        }
		//converts cards values into 1-13
		for (int index = 1; index < 53; index++)
		{
			deck[index] = (deck[index]/4)+1;
		}
    }
}
/*************************************************************/
void winlose(int total1, int total2)
{
	int answe;
	if(total1 >= total2)
	{
		cout<<"you lose... "<<endl<<endl;
		cout<<"Would you like to play again? (y/n) ";
		cin>>answe;
		if (answe == 'y')
		{
			int main();
		}
	}
	else
	{
		cout<<"YOU WIN!!!!!!! "<<endl<<endl;
		cout<<"Would you like to play again? (y/n) ";
		cin>>answe;
		if (answe == 'y')
		{
			int main();
		}
	}
}
/*************************************************************/
//Source.cpp
//Austin
//Mar. 25, 2008
//Im not a very experianced programmer so i have been trying to run the program with functions.  
//the finished product will need a class.

#include <iostream>
#include <iomanip>
#include <time.h>
#include <vector>
#include "deck.h"
using namespace std;

void intro();
void carddeck(int deck[53]);
void cards(int deck[53], int howmany, int count, int player, int total1, int total2);
void comp(int deck[53], int howmany, int count, int player, int total1, int total2);
void player(int deck[53], int howmany, int count, int player, int total1, int total2);
void winlose(int total1, int total2);

int main()
{
	int deck[53];
	int howmany = 0;
	int count = 1;   //keeps track of the cards that have been removed from deck
	int total1 = 0;
	int total2 = 0;
	int player = 0;
	intro();
	carddeck(deck[53]);
	comp(deck[53], howmany, count, player, total1, total2);
	
	
	return 0;
}

Lines 30 and 31. Arrays are not passed that way. Your functions want the entire array. deck[53] is a single integers and it's also a segmentation fault since deck's indexes only exist from 0 to 52. Instead of this:

carddeck(deck[53]);

the call should be this:

codedeck (deck);

Make that change every time you are trying to pass an entire array to a function. Leave the brackets off. The brackets go with the function headers, not the function calls.

The problem's in your code; without seeing your code it's a bit hard to see where the problem is...

No it's not. Almost every error is ... error C2664: 'carddeck' : cannot convert parameter 1 from 'int' to 'int []' You are passing an integer in parameter 1 of carddeck and the function wants an integer array. Read the errors and look at the lines specified. Then look at the variable types and find the mismatch.

Thank you VernonDozier, now I only have 2 errors and 2 warnings.

1>------ Build started: Project: FinalProject, Configuration: Debug Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>SOurce.cpp
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(71) : error C2064: term does not evaluate to a function taking 6 arguments
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(271) : warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(292) : error C2059: syntax error : '}'
1>Build log was saved at "file://c:\Documents and Settings\Austin\Desktop\Austin\FinalProject\Debug\BuildLog.htm"
1>FinalProject - 2 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Thank you VernonDozier, now I only have 2 errors and 2 warnings.

1>------ Build started: Project: FinalProject, Configuration: Debug Win32 ------
1>Compiling...
1>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
1>SOurce.cpp
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(71) : error C2064: term does not evaluate to a function taking 6 arguments
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(271) : warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data
1>c:\documents and settings\austin\desktop\austin\finalproject\source.cpp(292) : error C2059: syntax error : '}'
1>Build log was saved at "file://c:\Documents and Settings\Austin\Desktop\Austin\FinalProject\Debug\BuildLog.htm"
1>FinalProject - 2 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Ignore the warnings for now, focus on the errors. The second one (line 292) is due to this:

do 
   {    
        // Shuffles cards
        for (int index = 1; index < (53-1); index++) 
	{
            int r = index + (rand() % (53-index));
            int temp = deck[index]; deck[index] = deck[r]; deck[r] = temp;
        }
		//converts cards values into 1-13
	for (int index = 1; index < 53; index++)
	{
		deck[index] = (deck[index]/4)+1;
	}
    }

You have a "do" without a "while" at the end. For the first one, repost your new function call and, if you have changed the function header at all (which I don't think you needed to do), repost it too.

I just removed that do loop and the error is gone.

source.cpp(71) : error C2064: term does not evaluate to a function taking 6 arguments

SOurce.cpp

Attachments
//Source.cpp
//Austin
//Mar. 25, 2008
//Im not a very experianced programmer so i have been trying to run the program with functions.  
//the finished product will need a class.

#include <iostream>
#include <iomanip>
#include <time.h>
/*#include <vector>
#include "deck.h" */
using namespace std;

void intro();
void carddeck(int deck[53]);
void cards(int deck[53], int howmany, int count, int player, int total1, int total2);
void comp(int deck[53], int howmany, int count, int player, int total1, int total2);
void player(int deck[53], int howmany, int count, int player, int total1, int total2);
void winlose(int total1, int total2);

int main()
{
	int deck[53];
	int howmany = 0;
	int count = 1;   //keeps track of the cards that have been removed from deck
	int player = 0;
	int total1 = 0;
	int total2 = 0;
	
	intro();
	carddeck(deck);
	comp(deck, howmany, count, player, total1, total2);
	
	
	return 0;
}
/*************************************************************/
void intro()
{
	cout<<"Hello and welcome to: "<<endl<<endl;
	cout<<" ----    |      / \\    ---  |  /     |   / \\     ---  |  / "<<endl; 
	cout<<" |   |   |     |   |  |     | /      |  |   |   |     | /  "<<endl;
	cout<<" |--<    |     |---|  |     |/       |  |---|   |     |/   "<<endl;
	cout<<" |   |   |     |   |  |     | \\   |  |  |   |   |     | \\  "<<endl;
	cout<<" ----    ----  |   |   ---  |  \\   --   |   |    ---  |  \\ "<<endl;
	cout<<"\n                                         Casino Style      "<<endl<<endl;
	cout<<"In the game of Blackjack the object is to beat the dealer. You "<<endl;
	cout<<"will be dealt two cards and so will the dealer.  The object is"<<endl;
	cout<<"to get ""BlackJack"" or 21 points or beat the dealer by getting a "<<endl;
	cout<<"higher score without ""Busting"" (or going over 21). "<<endl<<endl;
}
/*************************************************************/
void comp(int deck[53], int howmany, int count, int player, int total1, int total2)
{
	cout<<"The computer will start: "<<endl;
	char answ;
	player = 1;
	howmany = 2;
	cards(deck, howmany, count, player, total1, total2);
	do
	{
		if (total1 <= 16)
		{
			howmany = 1;
			cards(deck, howmany, count, player, total1, total2);
		}
		else
		{
			if (total1 <=21)
			{
				player(deck, howmany, count, player, total1, total2);
			}
			else
			{
				cout<<"The computer has BUSTED "<<endl;
				cout<<"YOU WIN!!!!!!! "<<endl<<endl;
				cout<<"Would you like to play again? (y/n) ";
				cin>>answ;
				if (answ == 'y')
				{
					int main();
				}
			}
		}
	}
	while((total1 <= 16)&&(total1 <= 21));
}
/*************************************************************/
void player(int deck[53], int howmany, int count, int player, int total1, int total2)
{
	cout<<"Now its your turn: "<<endl;
	cout<<"Here are your cards: "<<endl<<endl;
	char ans;
	player = 2;
	howmany = 2;
	cards(deck, howmany, count, player, total1, total2);

	do
	{
		cout<<"Would you like to hit? (y/n) ";
		cin>>ans;
		if ((ans = 'y')&&(total2 >= 21))
		{
			howmany = 1;
			cards(deck, howmany, count, player, total1, total2);
		}
		else
		{
			cout<<"You BUSTED..."<<endl;
			winlose(total1, total2);
		}
	}
	while((ans = 'y')&&(total2 <=21));
}
/*************************************************************/
void cards(int deck[53], int howmany, int count, int player, int total1, int total2)
{	//displays a text image of a card instead of a number
	int choice;
	int counter = 0;
	
	do
	{
		choice = deck[count];
		
		if (player == 1)
		{
			total1 = total1 + deck[count];
		}
		if (player == 2)
		{
			total2 = total2 + deck[count];
		}
		count++;

		switch (choice)
		{
		case 1:
			cout<<"  _________  "<<endl;
			cout<<"  |A      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  | (11)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      A|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 2:
			cout<<"  _________  "<<endl;
			cout<<"  |2      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (2)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      2|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 3:
			cout<<"  _________  "<<endl;
			cout<<"  |3      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (3)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      3|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 4:
			cout<<"  _________  "<<endl;
			cout<<"  |4      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (4)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      4|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 5:
			cout<<"  _________  "<<endl;
			cout<<"  |5      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (5)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      5|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 6:
			cout<<"  _________  "<<endl;
			cout<<"  |6      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (6)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      6|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 7:
			cout<<"  _________  "<<endl;
			cout<<"  |7      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (7)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      7|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 8:
			cout<<"  _________  "<<endl;
			cout<<"  |8      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (8)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      8|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 9:
			cout<<"  _________  "<<endl;
			cout<<"  |9      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  |  (9)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      9|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 10:
			cout<<"  _________  "<<endl;
			cout<<"  |10     |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  | (10)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |     10|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 11:
			cout<<"  _________  "<<endl;
			cout<<"  |J      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  | (10)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      J|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 12:
			cout<<"  _________  "<<endl;
			cout<<"  |Q      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  | (10)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      Q|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		case 13:
			cout<<"  _________  "<<endl;
			cout<<"  |K      |  "<<endl;
			cout<<"  | Black |  "<<endl;
			cout<<"  | (10)  |  "<<endl;
			cout<<"  | Jack  |  "<<endl;
			cout<<"  |      K|  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		default:
			cout<<"  _________  "<<endl;
			cout<<"  |       |  "<<endl;
			cout<<"  |       |  "<<endl;
			cout<<"  | ERROR |  "<<endl;
			cout<<"  |       |  "<<endl;
			cout<<"  |       |  "<<endl;
			cout<<"  |_______|  "<<endl<<endl;
			break;
		}
		counter++;
	}
	while(counter < howmany);
}
/*************************************************************/
void carddeck(int deck[53])
{
    srand(time(0));

    for (int index = 1; index < 53; index++) 
	{
        deck[index] = index;  // fill the array in order 1-52
    }
      
	// Shuffles cards
    for (int index = 1; index < (53-1); index++) 
	{
		int r = index + (rand() % (53-index));
        int temp = deck[index]; deck[index] = deck[r]; deck[r] = temp;
    }
	//converts cards values into 1-13
	for (int index = 1; index < 53; index++)
	{
		deck[index] = (deck[index]/4)+1;
	}
}
/*************************************************************/
void winlose(int total1, int total2)
{
	int answe;
	if(total1 >= total2)
	{
		cout<<"you lose... "<<endl<<endl;
		cout<<"Would you like to play again? (y/n) ";
		cin>>answe;
		if (answe == 'y')
		{
			int main();
		}
	}
	else
	{
		cout<<"YOU WIN!!!!!!! "<<endl<<endl;
		cout<<"Would you like to play again? (y/n) ";
		cin>>answe;
		if (answe == 'y')
		{
			int main();
		}
	}
}
/*************************************************************/

I just removed that do loop and the error is gone.

source.cpp(71) : error C2064: term does not evaluate to a function taking 6 arguments

[ATTACH]5596[/ATTACH]

void comp(int deck[53], int howmany, int count, int player, int total1, int total2)
{
cout<<"The computer will start: "<<endl;
char answ;
player = 1;
howmany = 2;
cards(deck, howmany, count, player, total1, total2);
do
{
if (total1 <= 16)
{
howmany = 1;
cards(deck, howmany, count, player, total1, total2);
}
else
{
if (total1 <=21)
{
player(deck, howmany, count, player, total1, total2);
}
else
{
cout<<"The computer has BUSTED "<<endl;
cout<<"YOU WIN!!!!!!! "<<endl<<endl;
cout<<"Would you like to play again? (y/n) ";
cin>>answ;
if (answ == 'y')
{
int main();
}
}
}
}
while((total1 <= 16)&&(total1 <= 21));
}

You have an integer called "player" (lines 1, 5, 7, 13, 19 (in parameter list)) and a function called "player" (line 19). The compiler is getting confused about which "player" you are referring to. Change the integer player to something else in the lines above (1, 5, 7, 13, 19) and keep the function called "player" the same. To avoid confusion, at the top of your file change this line to whatever you changed that integer to in the function:

void player(int deck[53], int howmany, int count, int player, int total1, int total2);

The compiler will let you get away with it, but changing the name will avoid confusion. You should probably change any integer in "main" called "player" to something else too to avoid confusion.

Thanks you guys for all your help!

My last question is how would i use the class in Microsoft visual C++. It is giving me some errors because it doesn't recognize vectors.

Thanks you guys for all your help!

My last question is how would i use the class in Microsoft visual C++. It is giving me some errors because it doesn't recognize vectors.

That seems very odd to me. I have to believe that Visual C++ allows you to use vectors. Post the code and the exact error please.

This question has already been answered. Start a new discussion instead.