Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ Creating Functions question

Name: Wut? 2013-09-30 20:05

I'm attempting to create a DnD stat generator. I've created a function previous to the one I'm about to post that I didn't have any trouble with, but this one doesn't want to work.

int mod(x)
{

    int x1;

    if ( x == 18 )
        x1 = 4;

        //Yadayada if else statements

    return x1;
}

int main (void)
{
    srand(time(NULL));

    int x[6];

    for (int i = 0; i < 5; i++)
    {
        x[i] = roll();
    }

    for ( int i = 0, x1 = 0, x2 = 0; i < 5; i++)
    {
        cout << x[i] << " " <<
        x1 = x[i];
        x2 = mod(x1); // This being where I have trouble
                              // Function just doesn't want to run
        if ( x2 >= 1 )
            cout << "+" << x2 << endl;
        else
            cout << x2 << endl;
    }



    return 0;

}

Name: Anonymous 2013-10-01 17:23

Why aren't you passing by reference?
Why your x[5] doesn't get roll()?
Why are you cout for integers?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List