How can I get multiple output from a function?
How can I get multiple output from a function?
Maybe BRING what you want into the function, via pointer - then make your changes it to, and there's nothing that need be returned.
Or return a pointer to an array of something
Or return a pointer to a struct with all the struct members you need.
Sound OK to you?
the function is:
Code:bool CLA ( bool x0 , bool x1 , bool x2 , bool x3 , bool y0 , bool y1 , bool y2 , bool y3 , bool y4 , bool cn) { bool c0 , c1 , c2 , co , s0 , s1 , s2 , s3; c0 = ( x0 & y0 ) | ( ( x0 ^ y0 ) & cn ); c1 = ( x1 & y1 ) | ( ( x1 ^ y1 ) & c0 ); c2 = ( x2 & y2 ) | ( ( x2 ^ y2 ) & c1 ); co = ( x3 & y3 ) | ( ( x3 ^ y3 ) & c2 ); s0 = ( ( x0 ^ y0 ) ^ cn ); s1 = ( ( x1 ^ y1 ) ^ c0 ); s2 = ( ( x2 ^ y2 ) ^ c1 ); s3 = ( ( x3 ^ y3 ) ^ c2 ); // I want to return s3, s2, s1, s0 }
Looks like a natural to bring in the s[] array into the function. Then don't worry about a return at all, there's no return needed.
s[0] = s0;
s[1] = s1;
//etc.
You're very brave to have both a c0 and a co variable, in the same function.
Truth be told, I would think about using arrays for lots of these other bool variables, as well.
thank you