Can a C function return 2 values?

Status
Not open for further replies.
Re: c function ?

No. The work around is you can update any number of values in an array or structure which is declared globally and then use the updated values in the global variable.
 
c function ?

You could put the two values into a struct, and then return the struct.
 

Re: c function ?

Just a hint...
In my experience, the function should return an error code, usually.
And te real "returned" values(computed in the function body) should be returned via function parameters.
 

c function ?

That's probably not the best approach if, for example, the function returns the product of two complex numbers.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…