# Thread: Save values in a function

1. ## Save values in a function

It's supposed to generate binary numbers like this :
00 01 10 11 000 001 010 011 ....

And count how many times they appear in sir[].

At the end of function Suma, I have the binary sequence in v[] and the number in nr.
I'm using indice to copy them into secv[][] (the binary sequence) and *apar (how many times it appears in sir[]).

However, indice resets every time I call Memorare().

Is there any other way to do this?

Edit:
Removed the code.
I managed to fix it on my own, thanks to everyone who's trying to help!

2. >>However, indice resets every time I call Memorare().
I don't get it.

3. Originally Posted by Bayint Naung
>>However, indice resets every time I call Memorare().
I don't get it.
First time I call Memorare() in main, for i = 2, it does this:
Creates 00, 01, 10, 11. Indice will be 0, 1, 2, 3.

When i = 3, it creates 000, 001, 010, 011, 100, 101, 110, 111.
But indice goes 0, 1, 2, 3, 4, 5, 6, 7, instead of 4, 5, 6, 7, 8, 9, 10, 11.

4. hum?
Are you trying to do something like this:
Code:
```void change_it(int a)
{
a = 4;
}

....
int n = 10;
change_it(n);
// still 10 coz n is pass by value

void change_it(int *a)
{
*a = 4;
}

...
int n = 10;
change_it(&n);
// now n is 4```