So i have been trying to make a program that uses a function to roll a dice. I made the program so that the dice roll is within main but I'd like to make the dice roll a function all in itself so that i can use it for multiple things. This is what i have so far in the file attached and below copied and pasted:
#include <iostream>
#include <ctime> // for time function
#include <cstdlib> // for rand and srand functions
using namespace std;
int target, roll;
long count;
int rollDie(int target, int roll) {
long x;
while(roll != target){
roll = rand() % 6 + 1;
x++;
}
return x;
}
int main(){
srand((int)time(0));
cout << "Enter target (ctrl-z to exit): ";
cin >> target;
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.