function isnt returning the right numbers

im making a function to calculate stats for a text rpg i am making(this is just part of the actual game). i input the numbers and when i display the numbers i inputted in the call it gives me some really big numbers that i dont know is. i want to use the numbers that the function returns for other calculations during the game.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>

using namespace std;

int StatCalcW(int str, int stam)
{
     int ptsleft = 50;

while(ptsleft > 0)
    {
        cout << "Select your stats - 50 total points for strength and stamina" << endl;
        cout << "Points in strength: ";
        cin >> str;

            ptsleft = ptsleft - str;

        cout <<  "Select points in stamina (Hint - everypoint in stamina is 2 hp): ";
        cin >> stam;

            ptsleft = ptsleft - stam;


    }

    cout << "You have picked:" << endl;
    cout << str << " Points in strength." << endl;
    cout << stam << " Points in stamina." << endl;

    return str, stam;
}

int main()
{

    int PlayerStrength, PlayerStamina;

    StatCalcW(PlayerStrength, PlayerStamina);

    cout << PlayerStrength << endl;
    cout << PlayerStamina << endl;

    return 0;
}


say i enter 20 for strength and 30 for stamina then it will give me:
4585658145 and 569879565 when i check to see the what playerstrength and playerstamina is.
Last edited on
you did not initialize the values of PlayerStrength and PlayerStamina, thats the reason why they have these random values.
You seem really confused on how functions work...go read this:
http://www.cplusplus.com/doc/tutorial/functions/
Topic archived. No new replies allowed.