Zelaron Gaming Forum  
Stats Arcade Portal Forum FAQ Community Calendar Today's Posts Search
Go Back   Zelaron Gaming Forum > The Zelaron Nexus > Science and Art > Tech Help

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next

 
Post C++ Randomity Help
Reply
Posted 2004-01-02, 02: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
 



 

Bookmarks

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules [Forum Rules]
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 12:16 AM.
'Synthesis 2' vBulletin 3.x styles and 'x79' derivative
by WetWired the Unbound and Chruser
Copyright ©2002-2008 zelaron.com
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
This site is best seen with your eyes open.