# Visual Studio Help - How to make .exe?



## bruestle2

I wrote and auto dice roller that asks for sides on a die, number of dice, and then a modifier to that value. Great for DnD!
It also has an option to add the current total to the next total.

I have a few questions about my c++ program that I wrote:
1) How do you get Visual Studio to make an .exe out of your program?
2) Would the random function lose its randomness the way that I have the program set up? And if so, how would I fix it?
3) Are there any possible issues you might see with this? (Other than if the user enters the wrong data type...I am not adding checks for that)
4) If you want the code for yourself...take it.

Just the random function:

Code:



Code:


#include <ctime>    // For time()
#include <cstdlib>  // For srand() and rand()

.........

cout<<endl<<"Dice rolls: ";
for(i=0; i<numberofdice; i++)
{
roll = (rand() % die) + 1;
total = total + roll;

cout<<roll<<" ";

}
........

Code:



Code:


//My Name :D
//3-2-08
//Auto Dice Roller

#include <iostream>  //Preprocessing directive for input and output
#include <ctime>    // For time()
#include <cstdlib>  // For srand() and rand()
using namespace std;

int main ()
{
int die, numberofdice, roll, mod, total=0, i=0, prevtotal=0;
bool cont=true;
char add='n';

srand(time(0));  // Initialize random number generator.

do
{
                // Initial user input
cout<<"Number of sides on die = ";
cin>>die;
cout<<"Number of dice to roll = ";
cin>>numberofdice;
cout<<"Number add to the total = ";
cin>>mod;

                //Generate random dice rolls and output the values
cout<<endl<<"Dice rolls: ";
for(i=0; i<numberofdice; i++)
{
roll = (rand() % die) + 1;
total = total + roll;

cout<<roll<<" ";

}

                //Add integer modifier to total
total = total + mod;

                //Output Modifier value and totals
cout<<endl<<"Modifier = "<<mod<<endl;
cout<<"Dice total = "<<total<<endl;

                //If the last loop was supposed to be added to this loop,
                //it will output two extra lines
                if (add == 'y')
{
cout<<"Total from last round = "<<prevtotal<<endl;
total = total + prevtotal;
cout<<"Total = "<<total<<endl;
}

//Ask use if totals from this loop should be added to next loop
cout<<endl<<"Would you like to add this to the next total? y/n ";
cin>>add;

   cout<<"===================================="<<endl<<endl<<endl;

                //If the loops should be added, store the total value into prevtotal
if (cin == "y")
{
}
else
prevtotal = total;

total = 0;

} while (cont == true);  //Loop infinitively until user closes program
return 0;
}


----------



## Licht

Open My Documents. Open Visual Studio 2008. Open Projects. Open the project you want the EXE for. Open Bin. Open Debug. Should be first file in the list.


----------



## bruestle2

LOL...so I had already solved my issue!


----------



## Licht

Quote:


Originally Posted by *bruestle2* 
LOL...so I had already solved my issue!

If you need anything else just gimme a ring.


----------



## ghell

Quote:


Originally Posted by *bruestle2* 
1) How do you get Visual Studio to make an .exe out of your program?

Hit build to compile it.

Quote:


Originally Posted by *bruestle2* 
2) Would the random function lose its randomness the way that I have the program set up? And if so, how would I fix it?
3) Are there any possible issues you might see with this? (Other than if the user enters the wrong data type...I am not adding checks for that)

Computers are very bad at generating random numbers. The pseudorandom number generator you are using should not be used anywhere that true randomness is required (such as cryptography or card shuffling algorithms for a gambling website). There are probably system calls to get real entropy from the system to generate the numbers but this is platform specific and I don't know what they are. I assume they are somewhere in the Win32 API.


----------

