Got an error message (commented below) any help would be appreciated
thx
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, const char * argv[])
{
int currentNumber=0;
int computerMove;
int humanMove;
int test;
int turnCounter=0;
cout<<"Let’s Play 21! Rules: Each player can either add 1, 2, or 3 to the current number which starts at zero. The goal is to force your opponent to say 21. If that happens, you win! Good luck...I'll go first...";
currentNumber=(1+srand(time(NULL))%3);//"Invalid Operands to a bunary expression 'Void and Int'"
cout<<currentNumber;
(turnCounter++);
srand() and rand() are 2 different functions. You are attempting to use srand() as if it were rand():
You want to do this:
currentNumber=(1+rand()%3); // <- don't use srand here
srand is used to initialize the random number generator. You should call it once at the start of your program to ensure you get a different string of random numbers every time the program is run.
1 2 3 4
int main(int argc, constchar * argv[])
{
srand(time(NULL)); // <- do this once at the start of main
//...