View Single Post
 
Reply
Posted 2004-01-07, 11:40 AM in reply to Randuin's post "C++ Randomity Help"
I got VS6 and compiled this and it worked... tho the values were high



#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include <time.h>

using namespace std;
struct player_stats {
char name[25];
int age;
short str;
short wis;
short con;
} player;

int statGen(int stat)
{
srand ( (unsigned)time( NULL ) );
stat = rand();
return stat; //returns value now
}

void genChar(bool gender) //VOID now not INT
{
if (gender == 1)
{
player.age = statGen(0);
player.str = statGen(0) - 4;
player.wis = statGen(0) + 4;
player.con = statGen(0);
}
else
{
player.age = statGen(0);
player.str = statGen(0) + 4;
player.wis = statGen(0) - 4;
player.con = statGen(0);
}
cout << "Your are " << player.age << " years old!\n";
cout << "Your have " << player.str << " strength!\n";
cout << "Your have " << player.wis << " wisdom!\n";
cout << "Your have " << player.con << " constitution!\n";
}

int main(int argc, char *argv[])
{
genChar(1);
system("PAUSE");
return 0;
}
Old
Profile PM WWW Search
Acer enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHzAcer enjoys the static noises of ten television sets simultaneously tuned to 412.84 MHz
 
 
Acer