Hi there, I am starting to design a very simple game, I am not done with it, this is just a beginning of it, but I had a problem, I get the following error:and even if I change number of parameters used I still get that error.Code:'rng': function does not take 1 parameters
Is there something wrong with my code?
Thank you..
-Amy
Code:#include <iostream> #include <time.h> using namespace std; int rng(); int main() { char winlose; rng(winlose); cout<<winlose<<endl; return 0; } int rng(char state) { const int n = 6; // the number of faces of the dice int x1, x2, sum; // the 2 number generated by the RNG (x1 & x2), and their sum srand ( (unsigned) time (NULL) ); //Initialize RNG x1 = rand( ) % n + 1; // Generate a number from the sequence cout<<x1<<" "; // Print it x2 = rand( ) % n + 1; // Generate another number from the sequence cout<<x2<<endl; // Print it sum = x1 + x2; // summing the two randomly generated numbers cout<<sum<<endl; // if statment for checking if the sum of the 2 randomly generated numbers is 7 or 11 if((sum==7) || (sum==11)) state = 'w'; // w stands for win else if((sum==2) || (sum==3) || (sum==12)) state = 'l'; // l stands for lose else state = 'n'; // n stands for neither nor // end of if statment return state; }



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.