# Just a little snag

• 03-16-2005
StarOrbs
Just a little snag
Okay something I need to know is it possible to call a value from a void function to another void function?
What I want to do is for the number value in sumTwoPrimes function and send it to void prime to check if it's prime or not and it will send back 'n' or 'y' meaning if it's not prime or is prime. including the value of i and ans. I think I put the code into this post correctly for once. :)
The error I get from primeAns1 and primeAns2 in the function of sumTwoPrimes is error: value not ignored as it ought to be.
ALSO: THIS is not the entire program. only the two void functions.

Code:

```void prime(unsigned int &isPrime, char &primeAns) {         unsigned int i;                 if (isPrime == 0 || isPrime == 1)                 {                         primeAns = 'n';                 }                 for (i = 2; i < isPrime; i++)                 {                         if ((isPrime % i) == 0)                                 {                                         primeAns = 'n';                                         break;                                 }                         if (i == (isPrime - 1))                                 {                                         primeAns = 'y';                                 }                 }  } void sumTwoPrimes(unsigned int &isPrime, char &primeAns, char&primeAns1, char &primeAns2) {         unsigned int i;         unsigned int ans;                 for (i = isPrime; i < isPrime; i--)                 {                         ans = isPrime % i;                         primeAns1 = prime(ans, primeAns);                         primeAns2 = prime(i, primeAns);                                         if (primeAns1 == 'y' && primeAns2 == 'y')                                 {                                         break;                                 }                 } }```
• 03-16-2005
Salem
No, make the function return a result.
Or pass a reference to where you want the answer stored.
• 03-16-2005
StarOrbs
I thought I did pass a reference because I have char &primeAns in both functions.
• 03-16-2005
Salem
So perhaps

prime(ans, primeAns1);
prime(i, primeAns2);
• 03-16-2005
StarOrbs
Oh geez, lol.. That was a big Doh! Thanks salem.
• 03-16-2005
chrismax2