View Single Post
 
Post C++ Randomity Help
Reply
Posted 2004-01-02, 01:32 AM
Code:
#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();
}

int genChar(bool gender)
{
    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;
}
It's not randoming
Old
Profile PM WWW Search
Randuin is neither ape nor machine; has so far settled for the in-between
 
 
Randuin