how do I get the value from index in this function I made?

Hello I'm having problems with:

1.)How do I get the value of interger variable index outside of this function scope.

2.)How can I use this interger variable index with another function call.

I tried to use return but that didn't give me the results I wanted.


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
//index Assigner Function
int IndexAssigner(int clicktype, int index)
{

  int xm;

  int ym;

  SDL_GetMouseState(&xm,&ym);


  if(clicktype == 1)
  {

  
        //Index 1
        if(xm <= 100 && ym <= 100)
        {
        
          cout << "Hello this is a test" << endl;
          index = 1;
          cout << index << endl;
        
        }
        
        //Index 2
        if(xm >= 200 && ym >= 200)
        {
        
          cout << "Hello this is a test 2" << endl;
          index = 2;
          cout << index << endl;
        
        }

       

  }

  
  return index;



}


thank you :)
Last edited on
Topic archived. No new replies allowed.