Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Visual Studio Help - How to make .exe?
New Posts  All Forums:Forum Nav:

Visual Studio Help - How to make .exe?

post #1 of 5
Thread Starter 
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:
#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:
//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;
}

Edited by bruestle2 - 8/6/10 at 12:16pm
My Pwny!
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II 920 Asus M3A79-T Deluxe 6950 2GB 8GB @ 800Mhz 
Hard DriveOSPowerCase
Perc 5/i Raid 0 w/ 2x 320GB + Raid 5 w/ 6x 750GB Windows 7 x64 Pro Antec 850W Antec 1200 
  hide details  
Reply
My Pwny!
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II 920 Asus M3A79-T Deluxe 6950 2GB 8GB @ 800Mhz 
Hard DriveOSPowerCase
Perc 5/i Raid 0 w/ 2x 320GB + Raid 5 w/ 6x 750GB Windows 7 x64 Pro Antec 850W Antec 1200 
  hide details  
Reply
post #2 of 5
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.
Lee XT
(17 items)
 
  
CPUMotherboardGraphicsRAM
AMD FX-6300 Asus M5A97 SAPPHIRE Radeon HD 7850 AMD 4GB DDR3 1333MHZ 
RAMRAMRAMHard Drive
AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ OCZ Vertex 4 256GB 
CoolingOSMonitorKeyboard
Corsair H80 Windows 8.1 Pro MCE Dell P2414H WHXV7  Microsoft Generic 
PowerCaseMouseMouse Pad
Ultra 600W Limited Edition NZXT Black Steel Razer Deathadder Razer Goliath 
Audio
Realtek HD Audio 
  hide details  
Reply
Lee XT
(17 items)
 
  
CPUMotherboardGraphicsRAM
AMD FX-6300 Asus M5A97 SAPPHIRE Radeon HD 7850 AMD 4GB DDR3 1333MHZ 
RAMRAMRAMHard Drive
AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ OCZ Vertex 4 256GB 
CoolingOSMonitorKeyboard
Corsair H80 Windows 8.1 Pro MCE Dell P2414H WHXV7  Microsoft Generic 
PowerCaseMouseMouse Pad
Ultra 600W Limited Edition NZXT Black Steel Razer Deathadder Razer Goliath 
Audio
Realtek HD Audio 
  hide details  
Reply
post #3 of 5
Thread Starter 
LOL...so I had already solved my issue!
My Pwny!
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II 920 Asus M3A79-T Deluxe 6950 2GB 8GB @ 800Mhz 
Hard DriveOSPowerCase
Perc 5/i Raid 0 w/ 2x 320GB + Raid 5 w/ 6x 750GB Windows 7 x64 Pro Antec 850W Antec 1200 
  hide details  
Reply
My Pwny!
(13 items)
 
  
CPUMotherboardGraphicsRAM
Phenom II 920 Asus M3A79-T Deluxe 6950 2GB 8GB @ 800Mhz 
Hard DriveOSPowerCase
Perc 5/i Raid 0 w/ 2x 320GB + Raid 5 w/ 6x 750GB Windows 7 x64 Pro Antec 850W Antec 1200 
  hide details  
Reply
post #4 of 5
Quote:
Originally Posted by bruestle2 View Post
LOL...so I had already solved my issue!
If you need anything else just gimme a ring.
Lee XT
(17 items)
 
  
CPUMotherboardGraphicsRAM
AMD FX-6300 Asus M5A97 SAPPHIRE Radeon HD 7850 AMD 4GB DDR3 1333MHZ 
RAMRAMRAMHard Drive
AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ OCZ Vertex 4 256GB 
CoolingOSMonitorKeyboard
Corsair H80 Windows 8.1 Pro MCE Dell P2414H WHXV7  Microsoft Generic 
PowerCaseMouseMouse Pad
Ultra 600W Limited Edition NZXT Black Steel Razer Deathadder Razer Goliath 
Audio
Realtek HD Audio 
  hide details  
Reply
Lee XT
(17 items)
 
  
CPUMotherboardGraphicsRAM
AMD FX-6300 Asus M5A97 SAPPHIRE Radeon HD 7850 AMD 4GB DDR3 1333MHZ 
RAMRAMRAMHard Drive
AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ OCZ Vertex 4 256GB 
CoolingOSMonitorKeyboard
Corsair H80 Windows 8.1 Pro MCE Dell P2414H WHXV7  Microsoft Generic 
PowerCaseMouseMouse Pad
Ultra 600W Limited Edition NZXT Black Steel Razer Deathadder Razer Goliath 
Audio
Realtek HD Audio 
  hide details  
Reply
post #5 of 5
Quote:
Originally Posted by bruestle2 View Post
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 View Post
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.
Serene Power
(13 items)
 
  
CPUMotherboardGraphicsRAM
Dual Xeon E5620 Supermicro X8DAL-i EVGA 570HD SC 8GiB Corsair DDR3 1333 ECC-R 
Hard DriveOptical DriveOSMonitor
OCZ Agility 3 120GB SSD (+16TB NAS) LG 10x Blu-Ray Windows 7 x64 / Debian x64 Dell 2408WFP, P2411H 
PowerCase
850W CoolerMaster SilentPro M CoolerMaster Cosmos Pure 
  hide details  
Reply
Serene Power
(13 items)
 
  
CPUMotherboardGraphicsRAM
Dual Xeon E5620 Supermicro X8DAL-i EVGA 570HD SC 8GiB Corsair DDR3 1333 ECC-R 
Hard DriveOptical DriveOSMonitor
OCZ Agility 3 120GB SSD (+16TB NAS) LG 10x Blu-Ray Windows 7 x64 / Debian x64 Dell 2408WFP, P2411H 
PowerCase
850W CoolerMaster SilentPro M CoolerMaster Cosmos Pure 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Visual Studio Help - How to make .exe?