CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Is there a way to return two values from a function?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

Is there a way to return two values from a function?
PostPosted: Wed May 26, 2004 5:37 pm     Reply with quote

I wan't to write a function that receives two values and returns 2 values.

It is a table lookup routine that finds the bin position and fetch the value from 2 tables.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 26, 2004 5:43 pm     Reply with quote

Quote:
I want to write a function that receives two values and returns 2 values.

See the demo program at the end of this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=18265
valemike
Guest







PostPosted: Wed May 26, 2004 8:41 pm     Reply with quote

Yup, PCMPr. is correct. If you want to return two ints, you'll need to create a struct with at least two of those ints, and return the name of the struct, which is the same as returning a pointer to that struct.
Darren Rook



Joined: 06 Sep 2003
Posts: 287
Location: Milwaukee, WI

View user's profile Send private message Send e-mail

PostPosted: Thu May 27, 2004 8:09 am     Reply with quote

Or you can use pointers as a parameter in the function. Many times this is more effecient than passing and returning structures.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group