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;
}
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;
}