Here is the source code, it's supposed to be a card dealer program.
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <math.h>
using namespace std;
int rand_0toN1(int n);
void draw_a_card();
int select_next_available(int n)
while (true){
cout << "Enter number of cards to draw";
cout << "0 to exit";
cin >> n;
if (n==0)
break;
for ( i=1; i<=n; i++)
draw_a_card();
}
return 0;
}
void draw_a_card();
{
int r;
int s;
int n, card;
n= rand_0toN1(cards_remaining--);
card = select_next_available(n);
r = card % 13
s = card / 13
cout << ranks[r] << "of" << suits[s] << endl;
}
int select_next_available(int n)
{
int i = 0;
while (card_drawn[i]){
i++;}
while (n-->0){
i++;}
while (card_drawn[i]){
i++;}
}
card_drawn[i]=true;
return i;
}
int rand_0toN1(int n)
{
return rand() % n;
}
There are multiple errors I don't know how to fix, as i just learned this stuff.
The compiler is pretty straight forward about what the problems are. If it says that there should be a semicolon before something, then you need to put a semicolon at the end of the line before.
Your problems are:
line 9: missing semicolon
line 11: array should be named suits
line 15: missing semicolon
line 21: cast time( NULL ) to unsigned (this is only a warning though)
line 35: remove the semicolon
line 42: missing semicolon
line 43: missing semicolon
line 55: delete the curly brace, you have too many
I really only compiled your program, then paraphrased what the compiler said.