Overclock.net banner

1 - 2 of 2 Posts

Premium Member
5,410 Posts
Discussion Starter · #1 ·
I having problem trying to get the parameter return card being drawn. Any help is appreciated and will awarded.


// arrays as parameters
#include <iostream>
#include <conio.h>

using namespace std;

int main ()
int n, i;
string suits[4] = {"Hearts", "Diamonds", "Spades", "Clubs"};
string ranks[13] = {"Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};

while (1) {
cout << "Enter the number of card to draw: " << endl;
cin >> n;
if (n == 0)
for (i = 1; i<= n; i ++)
return 0;

void draw_a_card(int %r, int %s, string arg[]);

r = rand_0toN1(13);
s = rand_0toN1(4);

cout << ranks[r] << " of " << suits << endl;


int rand_0toN1(int n) {
return rand() % n;


2,667 Posts
Next time, use CODE instead of QUOTE tags.

As to your problem: you're not actually using the parameters for anything - you're declaring them as parameters, but you don't use the values for anything, instead you assign random values to them straight away. You've also put in 'string arg[]' which you don't use for anything.

Another problem is in your main function, when calling the function draw_a_card you aren't actually passing it any arguments (which it expects).

Since you don't actually seem to need the parameters for anything, I would just get rid of them and declare r and s inside the function.
1 - 2 of 2 Posts