Broken count function! Help!

I've been trying to solve this error for a few days now. I know i'm probably missing something simple. So i've made a function called numberOfX's
which takes 3 arguments and now takes a fourth argument, x and determines the number of dice rolls that equal the argument x.
I've extended the function to print out the number of 1s, 2s, .., 6s.

My problem lies in the print out the number of ...'s. specifically the number of 1's. this is what my compiler returns to me:
-----NUMBER OF---------
1's is: -1081144248
2's is: 0
3's is: 1
4's is: 0
5's is: 1
6's is: 1
[a1655620@ingb24w032]$

for some reason everything being returned is correct bar the "number of 1's".
any help or direction would be appreciated. here is my function:

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
45
46
47
48
49
50
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
	
void numberOfXs (int roll_1, int roll_2, int roll_3, int value)
{
  int countNumberOfValue = 0;
	
  if (roll_1 == value)
    {
      countNumberOfValue = countNumberOfValue + 1; 	
    }
    
  if (roll_2 == value)
    {
      countNumberOfValue = countNumberOfValue + 1; 	
    }   
	
  if (roll_3 == value)
    {
      countNumberOfValue = countNumberOfValue + 1; 	
    }

  cout << "Number of rolls equal to the value you entered is " <<countNumberOfValue<< "\n";
  cout << endl;
	
  cout << "-----NUMBER OF---------";
  cout<< endl;
	
  int roll = 1;
  int tempStore;
  while (roll <= 6)
    {
	
      if (roll_1== roll)
	tempStore++;
	      	
      if (roll_2 == roll)
	tempStore++;
	      	
      if (roll_3 == roll)
	tempStore++;
      cout <<roll<<"'s is: "<<tempStore<< "\n";
      roll++;
            
      tempStore = 0;
    }
}
Last edited on
tempStore is unitialized
dammit. That was so obvious. Been staring at it too long. thank you!
Topic archived. No new replies allowed.